Exemple #1
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var pattern = await _context.Pattern.FindAsync(id);

            var excGuidesToDelete = from i in _context.ExcurionGuide
                                    where i.Idpattern == id
                                    select i;

            foreach (var i in excGuidesToDelete)
            {
                ExcurionGuidesController.Delete(i.Id, _context);
                _context.ExcurionGuide.Remove(i);
            }
            _context.Pattern.Remove(pattern);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var guide = await _context.Guide.FindAsync(id);

            var excGuidesToDelete = (from i in _context.ExcurionGuide
                                     where i.Idguide == id
                                     select i).ToList();

            foreach (var i in excGuidesToDelete)
            {
                ExcurionGuidesController.Delete(i.Id, _context);
                _context.ExcurionGuide.Remove(i);
            }
            await _context.SaveChangesAsync();

            _context.Guide.Remove(guide);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }