예제 #1
0
        public ActionResult Edit([Bind(Include = "UserId,UserName,Nombre,Apellido,Direccion,Telefono,Celular,CityId")] User user)
        {
            if (ModelState.IsValid)
            {
                var db2 = new VMarketContext();

                var currentUser = db2.Users.Find(user.UserId);
                if (currentUser.UserName != user.UserName)
                {
                    UsersHelper.UpdateUserName(currentUser.UserName, user.UserName);
                }
                db2.Dispose();

                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CityId = new SelectList(db.Cities, "CityId", "Name", user.CityId);
            return(View(user));
        }