public async Task DeleteModuleAsync(int moduleId) { if (moduleId <= 0) { throw new ArgumentException($"Argument {nameof(moduleId)} can't be less or equal zero!"); } await moduleRepository.DeleteModuleAsync(moduleId); }
public async Task <IActionResult> DeleteConfirmed(string id) { try { await moduleRepository.DeleteModuleAsync(id); await moduleRepository.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch (DataAccessException e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Delete", "Error", new { errorMsg = ViewBag.ErrorMsg })); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } }