public async Task <IActionResult> CreateConfirm(DoctorCreateInputModel doctorCreateInputModel) { if (ModelState.IsValid) { var user = new CDGUser { UserName = doctorCreateInputModel.Username, Email = doctorCreateInputModel.Email }; var result = await _userManager.CreateAsync(user, doctorCreateInputModel.Password); if (result.Succeeded) { await _userManager.AddToRoleAsync(user, "Doctor"); return(Redirect("/")); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } return(this.View(doctorCreateInputModel)); }
public async Task <IActionResult> Create(DoctorCreateInputModel doctorCreateInputModel) { if (!ModelState.IsValid) { await GetAllDepartments(); return(View(doctorCreateInputModel)); } DoctorServiceModel doctorServiceModel = AutoMapper.Mapper.Map <DoctorServiceModel>(doctorCreateInputModel); await doctorService.Create(doctorCreateInputModel.Password, doctorServiceModel); return(Redirect("/Doctor/All")); }