Beispiel #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"));
        }
Beispiel #2
0
        public ActionResult Add(UsuarioViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            using (var db = new BD_PracticaEntities())
            {
                Usuario oUser = new Usuario();
                oUser.IdEstado = 1;
                oUser.Email    = model.Email;
                oUser.Edad     = model.Edad;
                oUser.Password = model.Password;

                db.Usuario.Add(oUser);

                db.SaveChanges();
            }
            return(Redirect(Url.Content("~/Usuario/Inicio")));
        }
Beispiel #3
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")));
        }