Exemplo n.º 1
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"));
 }