コード例 #1
0
        public ActionResult Editar(TablaViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (DemoWebEntities db = new DemoWebEntities())
                    {
                        var oTabla = db.Tabla.Find(model.ProgramaId);

                        oTabla.Nombre     = model.Nombre;
                        oTabla.Categoria  = model.Categoria;
                        oTabla.Fecha_Alta = model.Fecha_Alta;

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

                    return(Redirect("~/Tabla/"));
                }

                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #2
0
        public ActionResult Nuevo(TablaViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (DemoWebEntities db = new DemoWebEntities())
                    {
                        var oTabla = new Tabla();

                        oTabla.Nombre     = model.Nombre;
                        oTabla.Categoria  = model.Categoria;
                        oTabla.Fecha_Alta = model.Fecha_Alta;

                        db.Tabla.Add(oTabla);
                        db.SaveChanges();
                    }

                    return(Redirect("~/Tabla/"));
                }

                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #3
0
        public dynamic Add(dynamic postData)
        {
            var UserName = (string)postData.Name;
            var Password = (string)postData.Password;

            var user = new User()
            {
                UserName = UserName,
                Password = Password,
                IsActive = true
            };

            db.Users.Add(user);
            var rowCount = db.SaveChanges();

            return(rowCount);
        }
コード例 #4
0
        public ActionResult Eliminar(int Id)
        {
            using (DemoWebEntities db = new DemoWebEntities())
            {
                var oTabla = db.Tabla.Find(Id);
                db.Tabla.Remove(oTabla);
                db.SaveChanges();
            }


            return(Redirect("~/Tabla/"));
        }
コード例 #5
0
        public dynamic Add(dynamic postData)
        {
            var roleName = (string)postData.Name;
            var roleDesc = (string)postData.Desc;

            var role = new Role()
            {
                Name        = roleName,
                Description = roleDesc,
                IsActive    = true
            };

            db.Roles.Add(role);
            var rowCount = db.SaveChanges();

            return(rowCount);
        }