//--------------------------------------------- Updates -------------------------------------------- public static bool updateTaskChange(TaskChangeDTO pTaskChange) { using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString)) { SqlCommand command = new SqlCommand("usp_update_taskChange", connection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add("@id_taskChange", SqlDbType.Int); command.Parameters["@id_taskChange"].Value = pTaskChange.id_taskChange; command.Parameters.Add("@attribute_id", SqlDbType.Int); command.Parameters["@attribute_id"].Value = pTaskChange.attribute_id; command.Parameters.Add("@attributeList_id", SqlDbType.Int); command.Parameters["@attributeList_id"].Value = pTaskChange.attributeList_id; command.Parameters.Add("@operation_id", SqlDbType.Int); command.Parameters["@operation_id"].Value = pTaskChange.operation_id; command.Parameters.Add("@value", SqlDbType.NVarChar); command.Parameters["@value"].Value = pTaskChange.value; command.Parameters.Add("@userLog", SqlDbType.Int); command.Parameters["@userLog"].Value = pTaskChange.userLog; command.Connection.Open(); string result = command.ExecuteNonQuery().ToString(); if (result != "0") { return(true); } }; return(false); }
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 static List <TaskChangeDTO> getTaskChanges(string id_task) { List <TaskChangeDTO> taskChanges = new List <TaskChangeDTO>(); using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString)) { SqlCommand command = new SqlCommand("usp_get_TaskChanges", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@id_task", SqlDbType.Int); command.Parameters["@id_task"].Value = id_task; command.Connection.Open(); SqlDataReader rdr = command.ExecuteReader(); while (rdr.Read()) { TaskChangeDTO taskChange = new TaskChangeDTO(); taskChange.id_taskChange = rdr["id_taskChange"].ToString(); taskChange.task_id = rdr["task_id"].ToString(); taskChange.attribute_id = rdr["attribute_id"].ToString(); taskChange.attributeList_id = rdr["attributeList_id"].ToString(); taskChange.operation_id = rdr["operation_id"].ToString(); taskChange.value = rdr["value"].ToString(); taskChange.attributeList_type = rdr["attributeList_type"].ToString(); taskChange.attribute_type = rdr["attribute_type"].ToString(); taskChanges.Add(taskChange); } }; return(taskChanges); }
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 IHttpActionResult putTaskChange(TaskChangeDTO pTaskChange) { if (!TaskChangesData.updateTaskChange(pTaskChange)) { return(BadRequest()); } return(Ok()); }
public IHttpActionResult postTaskChange(TaskChangeDTO pTaskChange) { if (!TaskChangesData.insertTaskChange(pTaskChange)) { return(BadRequest()); } return(Ok()); }
public async Task <bool> putTaskChange(TaskChangeDTO taskChangeDTO) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(_BaseAddress); var userJson = new JavaScriptSerializer().Serialize(taskChangeDTO); HttpContent contentPost = new StringContent(userJson, Encoding.UTF8, "application/json"); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", getToken()); HttpResponseMessage response = client.PutAsync("api/tasks/dataChanges", contentPost).Result; return(response.IsSuccessStatusCode); } }
public TaskChange ConvertBblToDal(TaskChangeDTO entity) { return(new TaskChange(entity.Id, entity.TaskId, entity.EmployeeId, entity.ChangeText, entity.ChangeDate)); }