public async Task <ActionResult> Create(DoctorViewModel doctorViewModel) { if (ModelState.IsValid) { var user = UserManager.FindByEmail(doctorViewModel.Email); if (user == null) { Doctor doctor = DoctorViewModel.ToDoctor(doctorViewModel); user = await AddUser(doctorViewModel); ImageWorker imagePathGetter = new ImageWorker(); doctor.ImageUrl = imagePathGetter.GetImageStringPath(doctorViewModel.DoctorImage); if (doctorViewModel.DoctorImage != null) { doctorViewModel.DoctorImage.SaveAs(Path.Combine( Server.MapPath("~/AppFile/DoctorPictures"), doctor.ImageUrl)); } db.Doctors.Add(doctor); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(doctorViewModel)); }