// GET: Instructors/Delete/5 public async Task <IActionResult> Delete(int?id, [FromServices] IInstructorService service) { if (!id.HasValue) { return(NotFound()); } var hasPreviousError = TempData["HasError"] != null && Convert.ToBoolean(TempData["HasError"]); var message = Convert.ToString(TempData["Message"]); var instructor = await service.GetInstructorByIdForDetailAsync(id.Value); if (instructor == null) { // deleted by another user in previous delete request if (hasPreviousError) { TempData["Message"] = message; TempData["HasError"] = hasPreviousError; return(RedirectToAction(nameof(Index))); } return(NotFound()); // new delete request } return(View($"{_viewFolder}Delete.cshtml", instructor)); }
// GET: Instructors/Details/5 public async Task <IActionResult> Details(int?id, [FromServices] IInstructorService service) { if (!id.HasValue) { return(NotFound()); } var instructor = await service.GetInstructorByIdForDetailAsync(id.Value); if (instructor == null) { return(NotFound()); } return(View($"{_viewFolder}Details.cshtml", instructor)); }