public ActionResult Index() { LineaNegocioModel model = new LineaNegocioModel(); model.permisos = PermisosModulo.ObtenerPermisos(Modulo.LINEA_NEGOCIO); if (model.permisos == null) { TempData["message"] = "danger,No tiene pemisos"; return(Redirect("~/Home")); } return(View(ABSOLUTE_PATH)); }
public JsonResult Guardar(LineaNegocioModel 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)); } LineaNegocioDAO dao = new LineaNegocioDAO(); var entity = dao.GetById(model.Id, db); if (entity == null) { entity = new linea_negocio(); entity.NOMBRE = model.Nombre; entity.DESCRIPCION = model.Descripcion; entity.ID_UNIDAD_NEGOCIO = model.UnidadNegocio; entity.ACTIVO = model.Activo; db.linea_negocio.Add(entity); } else { entity.NOMBRE = model.Nombre; entity.DESCRIPCION = model.Descripcion; entity.ID_UNIDAD_NEGOCIO = model.UnidadNegocio; 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)); }