Пример #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/")));
        }
Пример #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"));
        }
Пример #3
0
        public ActionResult Add(UserViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            using (var db = new cursomvcEntities1())
            {
                user oUser = new user();
                oUser.idState  = 1;
                oUser.email    = model.Email;
                oUser.edad     = model.Edad;
                oUser.password = model.Password;

                db.user.Add(oUser);

                db.SaveChanges();
            }

            return(Redirect(Url.Content("~/User/")));
        }