Exemplo n.º 1
0
        public async Task <ActionResult> Delete(int id, Box box)
        {
            if (box == null)
            {
                return(RedirectToAction(nameof(Index)));
            }

            try
            {
                baseAsyncBoxRepo.Delete(box);
                await baseAsyncBoxRepo.SaveAsync();

                return(RedirectToAction(nameof(Index)));
            }
            catch (DbUpdateException /* dex */)
            {
                //Log the error (uncomment dex variable name after DataException and add a line here to write a log.
                return(RedirectToAction("Delete", new { id = id, saveChangesError = true }));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Delete(int id, Folder folder)
        {
            var folderToDelete = await baseAsyncFolderRepo.GetByConditionAsync(fld => fld.ID == id);

            ViewData["FolderBoxID"] = folderToDelete.BoxID;

            if (folder == null)
            {
                return(RedirectToAction(nameof(Index)));
            }

            try
            {
                baseAsyncFolderRepo.Delete(folder);
                await baseAsyncFolderRepo.SaveAsync();

                return(RedirectToAction("Index", new RouteValueDictionary(new { controller = "Box", action = "Index", id = ViewData["FolderBoxID"] ?? 1 })));
            }
            catch (DbUpdateException /* dex */)
            {
                //Log the error (uncomment dex variable name after DataException and add a line here to write a log.
                return(RedirectToAction("Delete", new { ID = id, saveChangesError = true }));
            }
        }