Example #1
0
 public ActionResult _AddAttributeList(Model.AddAttributeListModel pModel)
 {
     if (ModelState.IsValid)
     {
         AttributeTypeDTO attributesTypes = categorieProvider.getAttributeType(pModel.id_typeVA).Result;
         Regex            r = new Regex(attributesTypes.reg_expr);
         AttributeListDTO attributeListDTO = new AttributeListDTO();
         if (attributesTypes.reg_expr == "" || r.Match(pModel.valueVA).Success)
         {
             attributeListDTO.name         = pModel.attributeVA;
             attributeListDTO.value        = pModel.valueVA;
             attributeListDTO.type_id      = pModel.id_typeVA;
             attributeListDTO.user         = Request.Cookies["user_id"].Value;
             attributeListDTO.createdBy    = attributeListDTO.user;
             attributeListDTO.attribute_id = pModel.attribute_idVA;
             if (categorieProvider.postAttributeList(attributeListDTO).Result)
             {
                 return(_AttributeValuesList(pModel.attribute_idVA, pModel.attribute_nameVA));
             }
         }
         else
         {
             return(new HttpStatusCodeResult(404, "El campo valor es inválido"));
         }
     }
     return(new HttpStatusCodeResult(404, "Error, no se puede agregar el atributo"));
 }
Example #2
0
 public ActionResult _EditGeneralAttributeList(Model.EditAttributeListModel pModel)
 {
     if (ModelState.IsValid)
     {
         AttributeTypeDTO attributesType = categorieProvider.getAttributeType(pModel.id_type).Result;
         Regex            r = new Regex(attributesType.reg_expr);
         AttributeListDTO attributeListDTO = new AttributeListDTO();
         if (attributesType.reg_expr == "" || r.Match(pModel.value).Success)
         {
             attributeListDTO.name              = pModel.attribute;
             attributeListDTO.value             = pModel.value;
             attributeListDTO.type_id           = pModel.id_type;
             attributeListDTO.isEnabled         = pModel.isEnabled == "on" ? "true" : "false";
             attributeListDTO.user              = Request.Cookies["user_id"].Value;
             attributeListDTO.id_attributeValue = pModel.id_attributeValue;
             if (categorieProvider.putAttributeList(attributeListDTO).Result)
             {
                 return(new HttpStatusCodeResult(200));
             }
         }
         else
         {
             return(new HttpStatusCodeResult(404, "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"));
 }
 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 static bool updateAttributeList(AttributeListDTO pAttributeListDTO)
        {
            using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString))
            {
                SqlCommand command = new SqlCommand("usp_update_AttributeList", connection);
                command.CommandType = System.Data.CommandType.StoredProcedure;

                command.Parameters.Add("@id_attributeValue", SqlDbType.Int);
                command.Parameters["@id_attributeValue"].Value = pAttributeListDTO.id_attributeValue;
                command.Parameters.Add("@name", SqlDbType.NVarChar);
                command.Parameters["@name"].Value = pAttributeListDTO.name;
                command.Parameters.Add("@type_id", SqlDbType.Int);
                command.Parameters["@type_id"].Value = pAttributeListDTO.type_id;
                command.Parameters.Add("@value", SqlDbType.NVarChar);
                command.Parameters["@value"].Value = pAttributeListDTO.value;
                command.Parameters.Add("@isEnabled", SqlDbType.Bit);
                command.Parameters["@isEnabled"].Value = pAttributeListDTO.isEnabled;
                command.Parameters.Add("@pUser", SqlDbType.Int);
                command.Parameters["@pUser"].Value = pAttributeListDTO.user;

                command.Connection.Open();
                int result = command.ExecuteNonQuery();
                if (result != 0)
                {
                    return(true);
                }
                return(false);
            };
        }
        public static AttributeListDTO getAttributeList(string id_attributeValue)
        {
            AttributeListDTO attributeListDTO = new AttributeListDTO();

            using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString))
            {
                SqlCommand command = new SqlCommand("usp_get_AttributeList", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@id_attributeValue", SqlDbType.Int);
                command.Parameters["@id_attributeValue"].Value = id_attributeValue;
                command.Connection.Open();
                SqlDataReader rdr = command.ExecuteReader();
                while (rdr.Read())
                {
                    attributeListDTO.id_attributeValue = rdr["id_attributeValue"].ToString();
                    attributeListDTO.attribute_id      = rdr["attribute_id"].ToString();
                    attributeListDTO.name        = rdr["name"].ToString();
                    attributeListDTO.type_id     = rdr["type_id"].ToString();
                    attributeListDTO.value       = rdr["value"].ToString();
                    attributeListDTO.isEnabled   = rdr["isEnabled"].ToString();
                    attributeListDTO.createdBy   = rdr["createdBy"].ToString();
                    attributeListDTO.createdDate = rdr["createdDate"].ToString();
                }
            };
            return(attributeListDTO);
        }
 public IHttpActionResult putAtrributeList(AttributeListDTO pAttributeList)
 {
     if (!CategoriesData.updateAttributeList(pAttributeList))
     {
         return(BadRequest());
     }
     return(Ok());
 }
 public IHttpActionResult postAttributeList(AttributeListDTO pAttributeList)
 {
     if (!CategoriesData.insertAttributeList(pAttributeList))
     {
         return(BadRequest());
     }
     return(Ok());
 }
Example #8
0
        public ActionResult _DeleteGeneralAttributeList(string id_attributeValue)
        {
            AttributeListDTO attributeListDTO = new AttributeListDTO();

            attributeListDTO.id_attributeValue = id_attributeValue;
            attributeListDTO.user = Request.Cookies["user_id"].Value;;
            if (categorieProvider.deleteAttributeList(attributeListDTO).Result)
            {
                return(new HttpStatusCodeResult(200));
            }
            return(new HttpStatusCodeResult(404, "Error, el atributo no se puede eliminar"));
        }
 public async Task <bool> deleteAttributeList(AttributeListDTO pAttributeList)
 {
     using (var client = new HttpClient())
     {
         client.BaseAddress = new Uri(_BaseAddress);
         client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", getToken());
         HttpResponseMessage response = client.DeleteAsync("api/categories/attributesList/?id_attributeValue=" + pAttributeList.id_attributeValue + "&user=" + pAttributeList.user).Result;
         if (response.IsSuccessStatusCode)
         {
             return(true);
         }
         return(false);
     }
 }
 public async Task <bool> putAttributeList(AttributeListDTO pAttributeList)
 {
     using (var client = new HttpClient())
     {
         client.BaseAddress = new Uri(_BaseAddress);
         var         userJson    = new JavaScriptSerializer().Serialize(pAttributeList);
         HttpContent contentPost = new StringContent(userJson, Encoding.UTF8, "application/json");
         client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", getToken());
         HttpResponseMessage response = client.PutAsync("api/categories/attributesList", contentPost).Result;
         if (response.IsSuccessStatusCode)
         {
             return(true);
         }
         return(false);
     }
 }
        public async Task <AttributeListDTO> getAttributeList(string id_attributeValue)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(_BaseAddress);
                AttributeListDTO attributeList = new AttributeListDTO();
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", getToken());
                HttpResponseMessage response = client.GetAsync("api/categories/attributesList/?id_attributeValue=" + id_attributeValue).Result;
                if (response.IsSuccessStatusCode)
                {
                    string result = await response.Content.ReadAsStringAsync();

                    JavaScriptSerializer serializer = new JavaScriptSerializer();
                    attributeList = serializer.Deserialize <AttributeListDTO>(result);
                }
                return(attributeList);
            }
        }
        public AttributeListDTO getAttributeList(string id_attributeValue)
        {
            AttributeListDTO attribute = CategoriesData.getAttributeList(id_attributeValue);

            return(attribute);
        }