Ejemplo n.º 1
0
 public bool UpdateUserProfile(User_PF user)
 {
     try
     {
         _db.Entry(user).State = EntityState.Modified;
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
        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));
        }