public async Task <IActionResult> PostEdit( int?id, InstructorAddEditDto instructorDto, [FromServices] IInstructorService service) { if (!id.HasValue || id.Value != instructorDto.InstructorId) { return(NotFound()); } if (ModelState.IsValid) { try { await service.UpdateInstructorAndSaveAsync(instructorDto); } catch (GeneralException ex) { ViewBag.HasError = true; ViewBag.Message = ex.Message; } catch (Exception ex) { ViewBag.HasError = true; ViewBag.Message = Constants.ERROR_MESSAGE_STANDARD + ": " + ex.Message; } return(RedirectToAction(nameof(Index))); } await PopulateCourseAssignedDataAsync(instructorDto.CoursesAssigned, service); return(View($"{_viewFolder}Edit.cshtml", instructorDto)); }