public ActionResult DoctorEditeProfile(DoctorEditProfileViewModel profile) { var doctorId = User.Identity.GetUserId(); var doctor = db.Doctors.Where(x => x.Id == doctorId).SingleOrDefault(); if (!UserManager.CheckPassword(doctor, profile.CurrentPassword)) { ViewBag.Message = "كلمة السر غير صحيحة"; } else { doctor.UserName = profile.UserName; doctor.Email = profile.Email; doctor.Gender = profile.Gender; doctor.PhoneNumber = profile.PhoneNumber; doctor.BirthDate = profile.BirthDate; doctor.CityId = profile.CityId; db.Entry(doctor).State = EntityState.Modified; db.SaveChanges(); ViewBag.Message = "تم التحديث"; ViewBag.Country = db.Countries.ToList(); ViewBag.GovernorateId = new SelectList(db.Governorates.ToList(), "Id", "GovernorateName"); ViewBag.CityId = new SelectList(db.Cities.ToList(), "Id", "CitiesName"); } return(RedirectToAction("Index", "Doctors")); }
// GET: /Account/DoctorEditProfileViewModel public ActionResult DoctorEditeProfile() { ViewBag.Country = db.Countries.ToList(); ViewBag.GovernorateId = new SelectList(db.Governorates.ToList(), "Id", "GovernorateName"); ViewBag.CityId = new SelectList(db.Cities.ToList(), "Id", "CitiesName"); var doctorId = User.Identity.GetUserId(); var doctor = db.Doctors.Where(x => x.Id == doctorId).SingleOrDefault(); DoctorEditProfileViewModel profile = new DoctorEditProfileViewModel(); profile.UserName = doctor.UserName; profile.Email = doctor.Email; profile.Gender = doctor.Gender; profile.PhoneNumber = doctor.PhoneNumber; profile.BirthDate = doctor.BirthDate; profile.CityId = doctor.CityId; return(View(profile)); }