public bool UpdateUserProfile(User_PF user) { try { _db.Entry(user).State = EntityState.Modified; return(true); } catch (Exception) { return(false); } }
public ActionResult AccountSetting(User_PF user, HttpPostedFileBase ImgUp) { if (ModelState.IsValid) { if (ImgUp != null && ImgUp.IsImage()) { if (user.ImageName != "no-avatar.png") { System.IO.File.Delete(Server.MapPath("/Images/Student/" + user.ImageName)); } user.ImageName = Guid.NewGuid().ToString() + Path.GetExtension(ImgUp.FileName); ImgUp.SaveAs(Server.MapPath("/Images/Student/" + user.ImageName)); } _userRepository.UpdateUserProfile(user); _userRepository.save(); TempData["SuccessProfile"] = true; return(RedirectToAction("AccountSetting")); } return(View(user)); }