public ActionResult Index() { LineaProductoModel model = new LineaProductoModel(); model.permisos = PermisosModulo.ObtenerPermisos(Modulo.LINEA_PRODUCTO, db); if (model == null) { TempData["message"] = "danger,No tiene pemisos"; return(Redirect("~/Home")); } return(View(ABSOLUTE_PATH, model)); }
public JsonResult Guardar(LineaProductoModel model) { var rm = new ResponseModel(); if (!ModelState.IsValid) { rm.message = "Hubo un problema verifique sus datos e intente de nuevo."; rm.message += ExtensionMethods.GetAllErrorsFromModelState(this); return(Json(rm, JsonRequestBehavior.AllowGet)); } var entity = db.linea_producto.Find(model.Id); if (entity == null) { entity = new linea_producto(); entity.NOMBRE = model.Nombre; entity.DESCRIPCION = model.Descripcion; entity.ACTIVO = model.Activo; db.linea_producto.Add(entity); } else { entity.NOMBRE = model.Nombre; entity.DESCRIPCION = model.Descripcion; entity.ACTIVO = model.Activo; } if (db.SaveChanges() > 0 || db.Entry(entity).State == EntityState.Unchanged) { rm.response = true; rm.message = "Sus datos se guardaron correctamente"; rm.function = "reload(true,'" + rm.message + "')"; } return(Json(rm, JsonRequestBehavior.AllowGet)); }