public ActionResult EditProfile()
        {
            var userID = User.Identity.GetUserId();
            var user   = db.Users.Where(a => a.Id == userID).SingleOrDefault();
            EditProfilViewModel profile = new EditProfilViewModel();

            profile.UserName = user.UserName;
            profile.Email    = user.Email;
            return(View(profile));
        }
        public ActionResult EditProfile(EditProfilViewModel profile)
        {
            var userID      = User.Identity.GetUserId();
            var Currentuser = db.Users.Where(a => a.Id == userID).SingleOrDefault();

            Currentuser.UserName        = profile.UserName;
            Currentuser.Email           = profile.Email;
            db.Entry(Currentuser).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            ViewBag.Message = "Editing success.";
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 3
0
 public EditProfil()
 {
     InitializeComponent();
     BindingContext = new EditProfilViewModel();
 }