Exemplo n.º 1
0
        public ActionResult Delete(int id)
        {
            using (var db = new BD_PracticaEntities())
            {
                var oUser = db.Usuario.Find(id);
                oUser.IdEstado = 3;

                db.Entry(oUser).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }
            return(Content("1"));
        }
Exemplo n.º 2
0
        public ActionResult Edit(EditUsuarioViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            using (var db = new BD_PracticaEntities())
            {
                var oUser = db.Usuario.Find(model.IdUsuario);
                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("~/Usuario/Inicio")));
        }