public ActionResult UpdateMyProfile() { string id = User.Identity.GetUserId(); BasicAdmin BasicAdmin = db.BasicAdmins.Include(e => e.ApplicationUser).Where(x => x.Id == id).FirstOrDefault(); if (BasicAdmin != null) { return(View(BasicAdmin)); } else { return(HttpNotFound()); } }
public ActionResult UpdateMyProfile(BasicAdmin bAdmin, HttpPostedFileBase img) { var oldUser = db.Users.Where(x => x.Id == bAdmin.Id).FirstOrDefault(); string ext; string imgName; if (ModelState.IsValid) { if (oldUser != null) { oldUser.Fname = bAdmin.ApplicationUser.Fname; oldUser.Lname = bAdmin.ApplicationUser.Lname; oldUser.BDate = bAdmin.ApplicationUser.BDate; oldUser.Address = bAdmin.ApplicationUser.Address; if (img != null) { ext = img.FileName.Substring(img.FileName.LastIndexOf(".")); imgName = bAdmin.Id + ext; img.SaveAs(Server.MapPath("/Images/") + imgName); oldUser.Photo = "/Images/" + imgName; db.SaveChanges(); return(RedirectToAction(nameof(ViewProfile))); } else { db.SaveChanges(); return(RedirectToAction(nameof(ViewProfile))); } } else { return(HttpNotFound()); } } return(View(bAdmin)); }