public async Task <IActionResult> Create( InstructorAddEditDto instructorDto, [FromServices] IInstructorService service) { if (ModelState.IsValid) { try { await service.CreateInstructorAndSaveAsync(instructorDto); return(RedirectToAction(nameof(Index))); } catch (GeneralException ex) { ViewBag.HasError = true; ViewBag.Message = ex.Message; } catch (Exception ex) { _logger.LogError("Error in Create: " + ex.Message); ViewBag.HasError = true; ViewBag.Message = Constants.ERROR_MESSAGE_SAVE + ": " + ex.Message; } } await PopulateCourseAssignedDataAsync(instructorDto.CoursesAssigned, service); return(View($"{_viewFolder}Create.cshtml", instructorDto)); }