Esempio n. 1
0
        public ActionResult Edit(EditUserViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            using (var db = new cursomvcEntities1())
            {
                var oUser = db.user.Find(model.Id);
                oUser.email = model.Email;
                oUser.edad  = model.Edad;

                if (model.Password != null && model.Password.Trim() != "")
                {
                    oUser.password = model.Password;
                }

                db.Entry(oUser).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }


            return(Redirect(Url.Content("~/User/")));
        }
Esempio n. 2
0
        public ActionResult Delete(int Id)
        {
            using (var db = new cursomvcEntities1())
            {
                var oUser = db.user.Find(Id);
                oUser.idState = 3; //eliminaremos

                db.Entry(oUser).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }

            return(Content("1"));
        }