public ActionResult _AddTaskChange(Model.TaskChangesModel pModel)
 {
     if (ModelState.IsValid)
     {
         CategorieProvider categorieProvider = new CategorieProvider();
         TaskChangeDTO     taskChange        = new TaskChangeDTO();
         taskChange.task_id = pModel.task_idA;
         AttributeTypeDTO typeDTO;
         if (pModel.attribute_idA.Substring(0, 1) == "l")
         {
             taskChange.attributeList_id = pModel.attribute_idA.Substring(1);
             AttributeListDTO attributeListDTO = categorieProvider.getAttributeList(taskChange.attributeList_id).Result;
             typeDTO = categorieProvider.getAttributeType(attributeListDTO.type_id).Result;
         }
         else
         {
             taskChange.attribute_id = pModel.attribute_idA.Substring(1);
             GeneralAttributeDTO generalAttributeDTO = categorieProvider.getGeneralAttribute(taskChange.attribute_id).Result;
             typeDTO = categorieProvider.getAttributeType(generalAttributeDTO.type_id).Result;
         }
         if (!(typeDTO.reg_expr == "" || new Regex(typeDTO.reg_expr).Match(pModel.valueA).Success))
         {
             return(new HttpStatusCodeResult(404, "Error, el campo valor debe ser de tipo: " + typeDTO.type));
         }
         taskChange.operation_id = pModel.operation_idA;
         taskChange.value        = pModel.valueA.ToString();
         taskChange.userLog      = Request.Cookies["user_id"].Value;
         if (taskProvider.postTaskChange(taskChange).Result)
         {
             return(_TaskDataChangesList(taskChange.task_id));
         }
     }
     return(new HttpStatusCodeResult(404, "Error, no se puede agregar el cambio de dato"));
 }
 public ActionResult _EditTaskChange(Model.EditTaskChangeModel pModel)
 {
     if (ModelState.IsValid)
     {
         CategorieProvider categorieProvider = new CategorieProvider();
         TaskChangeDTO     taskChange        = new TaskChangeDTO();
         taskChange.id_taskChange = pModel.id_taskChange;
         AttributeTypeDTO typeDTO;
         if (pModel.attribute_id.Substring(0, 1) == "l")
         {
             taskChange.attributeList_id = pModel.attribute_id.Substring(1);
             typeDTO = categorieProvider.getAttributeType(pModel.attributeList_type).Result;
         }
         else
         {
             taskChange.attribute_id = pModel.attribute_id.Substring(1);
             typeDTO = categorieProvider.getAttributeType(pModel.attribute_type).Result;
         }
         if (!(typeDTO.reg_expr == "" || new Regex(typeDTO.reg_expr).Match(pModel.value).Success))
         {
             return(new HttpStatusCodeResult(404, "Error, el campo valor debe ser de tipo: " + typeDTO.type));
         }
         taskChange.operation_id = pModel.operation_id;
         taskChange.value        = pModel.value.ToString();
         taskChange.userLog      = Request.Cookies["user_id"].Value;
         if (taskProvider.putTaskChange(taskChange).Result)
         {
             return(new HttpStatusCodeResult(200));
         }
     }
     return(new HttpStatusCodeResult(404, "Error, no se puede editar el cambio de dato"));
 }
 public JsonResult _EditUserAttribute(Model.EditUserAttributeModel model)
 {
     if (ModelState.IsValid)
     {
         AttributeTypeDTO attributesType = categorieProvider.getAttributeType(model.type_id).Result;
         Regex            r = new Regex(attributesType.reg_expr);
         if (r.Match(model.value).Success)
         {
             PersonalAttributeDTOmin userAttribute = new PersonalAttributeDTOmin();
             userAttribute.attribute_id = model.attribute_id;
             userAttribute.value        = model.value;
             userAttribute.user_id      = model.user_id;
             userAttribute.userLog      = Request.Cookies["user_id"].Value;
             if (userProvider.putUserAttribute(userAttribute).Result)
             {
                 Response.StatusCode = 200;
                 return(Json(model, JsonRequestBehavior.AllowGet));
                 //return new HttpStatusCodeResult(200, "hola");
             }
         }
         Response.StatusCode        = 400;
         Response.StatusDescription = "El campo valor es incorrecto";
         return(Json(new { error = "El campo valor es incorrecto" }, JsonRequestBehavior.AllowGet));
     }
     Response.StatusCode        = 400;
     Response.StatusDescription = "Error, debe completar todos los campos";
     return(Json(new { error = "Error, debe completar todos los campos" }, JsonRequestBehavior.AllowGet));
 }
Beispiel #4
0
 public ActionResult _AddGeneralAttribute(Model.AddGeneralAttributeModel pModel)
 {
     if (ModelState.IsValid || (pModel.id_typeA == "4" && pModel.attributeA != null))
     {
         AttributeTypeDTO    attributesType = categorieProvider.getAttributeType(pModel.id_typeA).Result;
         Regex               r = new Regex(attributesType.reg_expr);
         GeneralAttributeDTO generalAttributeDTO = new GeneralAttributeDTO();
         if (attributesType.reg_expr == "" || r.Match(pModel.valueA).Success)
         {
             generalAttributeDTO.name         = pModel.attributeA;
             generalAttributeDTO.value        = pModel.valueA != null ? pModel.valueA : "";
             generalAttributeDTO.type_id      = pModel.id_typeA;
             generalAttributeDTO.user         = Request.Cookies["user_id"].Value;
             generalAttributeDTO.createdBy    = generalAttributeDTO.user;
             generalAttributeDTO.categorie_id = pModel.categorie_idA;
             if (categorieProvider.postGeneralAttribute(generalAttributeDTO).Result)
             {
                 return(_GeneralAttrList(pModel.categorie_idA));
                 //return _CategorieGeneralAtr(pModel.categorie_id);
             }
         }
         else
         {
             return(new HttpStatusCodeResult(404, "Error, el campo valor es inválido"));
         }
     }
     else
     {
         return(new HttpStatusCodeResult(404, "Error, debe completar todos los campos"));
     }
     return(new HttpStatusCodeResult(404, "Error, no se puede agregar el atributo"));
 }
Beispiel #5
0
 public string getTypeName(string id_type)
 {
     return(categorieProvider.getAttributeType(id_type).Result.type);
 }