public FormQuestionsModel(TaskDTO taskDTO) { //-- Get questions this.taskDTO = taskDTO; taskForm = taskProvider.getTaskFormbyTask(this.taskDTO.id_task).Result; if (taskForm.id_taskForm != null) { formQuestions = taskProvider.getFormQuestions(taskForm.id_taskForm).Result; } this.id_taskFormA = taskForm.id_taskForm; this.id_taskA = taskDTO.id_task; _QuestionTypesSelect = generateQuestionTypesSelect(); _AttributesSelect = generateAttributeTypesSelect(); //-- Max position foreach (var question in formQuestions) { int questionPosition = Int32.Parse(question.questionPosition); if (questionPosition >= maxQuestionPositionA) { maxQuestionPositionA = questionPosition + 1; } } addFormUsersModel = new AddFormUsersModel(taskDTO, taskForm); usersAnswered = taskProvider.getQuestionAnswersUsers(taskForm.id_taskForm).Result; }
public static bool updateForm(TaskFormDTO pTaskForm) { using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString)) { SqlCommand command = new SqlCommand("usp_update_form", connection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add("@id_taskForm", SqlDbType.BigInt); command.Parameters["@id_taskForm"].Value = pTaskForm.id_taskForm; command.Parameters.Add("@description", SqlDbType.NVarChar); command.Parameters["@description"].Value = pTaskForm.description; command.Parameters.Add("@userLog", SqlDbType.Int); command.Parameters["@userLog"].Value = pTaskForm.userLog; command.Connection.Open(); string result = command.ExecuteNonQuery().ToString(); if (result != "0") { return(true); } }; return(false); }
public IHttpActionResult putForm(TaskFormDTO pTaskForm) { if (!TaskFormData.updateForm(pTaskForm)) { return(BadRequest()); } return(Ok()); }
public IHttpActionResult postTaskForm(TaskFormDTO pTaskForm) { if (!TaskFormData.insertForm(pTaskForm)) { return(BadRequest()); } return(Ok()); }
public async Task <bool> putTaskForm(TaskFormDTO taskFormDTO) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(_BaseAddress); var userJson = new JavaScriptSerializer().Serialize(taskFormDTO); HttpContent contentPost = new StringContent(userJson, Encoding.UTF8, "application/json"); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", getToken()); HttpResponseMessage response = client.PutAsync("api/tasks/forms", contentPost).Result; return(response.IsSuccessStatusCode); } }
public AddFormUsersModel(TaskDTO taskDTO, TaskFormDTO taskFormDTO) { this.taskDTO = taskDTO; this.taskFormDTO = taskFormDTO; userList = taskProvider.getTaskParticipants(taskDTO.id_task).Result; this.taskForm_id = taskFormDTO.id_taskForm; List <SelectListItem> usersSelectList = new List <SelectListItem>(); foreach (ParticipantDTO iUser in userList) { var name = iUser.name + " " + iUser.fLastName + " " + iUser.sLastName; usersSelectList.Add(new SelectListItem { Text = name, Value = iUser.user_id }); } _ParticipantsSelect = new SelectList(usersSelectList, "Value", "Text"); formUsersModel = new FormUsersModel(taskFormDTO.id_taskForm); }
public ActionResult _EditTaskForm(string id_taskForm, string description) { if (ModelState.IsValid) { TaskFormDTO taskForm = new TaskFormDTO(); taskForm.id_taskForm = id_taskForm; taskForm.description = description; taskForm.userLog = Request.Cookies["user_id"].Value; if (taskProvider.putTaskForm(taskForm).Result) { return(Json(taskForm)); } } else { return(new HttpStatusCodeResult(404, "El campo descripción es incorreccto")); } return(new HttpStatusCodeResult(404, "Error, no se puede editar el formulario")); }
public async Task <TaskFormDTO> getTaskFormbyTask(string id_task) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(_BaseAddress); TaskFormDTO form = new TaskFormDTO(); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", getToken()); HttpResponseMessage response = client.GetAsync("api/tasks/forms?id_task=" + id_task).Result; if (response.IsSuccessStatusCode) { string result = await response.Content.ReadAsStringAsync(); form = new JavaScriptSerializer().Deserialize <TaskFormDTO>(result); } return(form); } }
public static TaskFormDTO getTaskFormbyTask(string id_task) { TaskFormDTO taskForm = new TaskFormDTO(); using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString)) { SqlCommand command = new SqlCommand("usp_getTaskFormbyTask", 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()) { taskForm.id_taskForm = rdr["id_taskForm"].ToString(); taskForm.id_task = rdr["task_id"].ToString(); taskForm.description = rdr["description"].ToString(); } }; return(taskForm); }
public ActionResult _AddFormUser(string taskForm_id, List <string> selected_userForm_id) { if (ModelState.IsValid) { List <TaskFormUserDTO> actualUsers = taskProvider.getFormUsers(taskForm_id).Result; if (actualUsers.Count < 1) { List <TaskFormUserDTO> users = new List <TaskFormUserDTO>(); if (selected_userForm_id.Count > 1) { return(new HttpStatusCodeResult(404, "Solamente se permite agregar un usuario")); } else { foreach (var responsable_id in selected_userForm_id) { TaskFormUserDTO formUser = new TaskFormUserDTO(); formUser.user_id = responsable_id; formUser.taskForm_id = taskForm_id; formUser.userLog = Request.Cookies["user_id"].Value; users.Add(formUser); } List <TaskFormUserDTO> addedUsers = taskProvider.postFormUsers(users).Result; int addedCount = addedUsers.Count; int errorCount = users.Count - addedCount; TaskFormDTO taskForm = taskProvider.getTaskForm(taskForm_id).Result; TaskDTO taskDTO = taskProvider.getTask(taskForm.id_task).Result; var result = new { usersAdded = addedCount, usersError = errorCount, viewHtml = PartialView("/Views/Tasks/_Tasks/_TaskDetails/_TaskFormUsersList.cshtml", new Model.AddFormUsersModel(taskDTO, taskForm)).RenderToString() }; return(Json(result)); } } else { return(new HttpStatusCodeResult(404, "Solamente se permite agregar un usuario")); } } return(new HttpStatusCodeResult(404, "Error, no se agregó ningun usuario")); }
public ActionResult _AnswerTaskForm(List <string> answers, string id_task) { if (ModelState.IsValid) { var parameters = Request.Params; TaskProvider taskProvider = new TaskProvider(); TaskFormDTO taskForm = taskProvider.getTaskFormbyTask(id_task).Result; List <TaskQuestionDTO> taskQuestions = taskProvider.getFormQuestions(taskForm.id_taskForm).Result; bool isFormAnswered = true; int iQuestion = 0; foreach (var question in taskQuestions) { TaskQuestionAnswerDTO questionAnswer = new TaskQuestionAnswerDTO(); questionAnswer.taskQuestion_id = question.id_taskQuestion; questionAnswer.user_id = Request.Cookies["user_id"].Value; questionAnswer.userLog = Request.Cookies["user_id"].Value; if (questionAnswer.questionType_id != "5") //string answer { questionAnswer.responseData = Encoding.UTF8.GetBytes(answers[iQuestion]); } if (questionAnswer.questionType_id != "4") //string answer { questionAnswer.responseData = Encoding.UTF8.GetBytes(answers[iQuestion]); } if (!taskProvider.postQuestionAnswer(questionAnswer).Result) { isFormAnswered = false; } iQuestion++; } if (isFormAnswered) { return(new HttpStatusCodeResult(200)); } } return(new HttpStatusCodeResult(404, "Error, no se puede agregar la notificación")); }
public ActionResult _AddTask(Model.AddTaskModel model) { if (ModelState.IsValid) { List <TaskDTO> tasks = taskProvider.getTasks(model.id_stage).Result; TaskDTO taskDTO = new TaskDTO(); taskDTO.name = model.name; taskDTO.description = model.description; taskDTO.stage_id = model.id_stage; taskDTO.type_id = model.selected_taskType; if (tasks.Count == 0) { taskDTO.taskPosition = "0"; } else { taskDTO.taskPosition = (Int32.Parse(tasks[tasks.Count - 1].taskPosition) + 1).ToString(); } if (model.timeSelected == "time") { taskDTO.daysAvailable = model.daysAmount; taskDTO.hoursAvailable = model.hoursAmount; } else if (model.timeSelected == "date") { taskDTO.finishDate = model.timeDatePicker + " " + model.timeHour; } taskDTO.userLog = Request.Cookies["user_id"].Value; string id_task; if ((id_task = taskProvider.postTask(taskDTO).Result) != null) { id_task = id_task.Replace("\"", ""); bool isSuccess = false; TaskTypeDTO taskType = taskProvider.getTaskType(taskDTO.type_id).Result; if (taskType.formNeeded == "True") { TaskFormDTO taskForm = new TaskFormDTO(); taskForm.id_task = id_task; taskForm.description = ""; taskForm.userLog = taskDTO.userLog; if (taskProvider.postTaskForm(taskForm).Result) { isSuccess = true; } } else { isSuccess = true; } if (isSuccess) { StageDTO stageDTO = new ProcessManagmentProvider().getStage(taskDTO.stage_id).Result; if (taskProvider.putRefreshTaskTimes(stageDTO.processManagment_id).Result) { var result = new { id_task = id_task, viewHtml = PartialView("/Views/Tasks/_Tasks/_TasksList.cshtml", new Model.TasksModel(taskDTO.stage_id)).RenderToString() }; return(Json(result)); } } } } return(new HttpStatusCodeResult(404, "Can't find that")); }
public EditTaskForm(TaskFormDTO taskForm) { this.taskFormDTO = taskForm; this.description = taskFormDTO.description; this.id_taskForm = taskFormDTO.id_taskForm; }
public TaskFormDTO getTaskForm(string id_taskForm) { TaskFormDTO taskForm = TaskFormData.getTaskForm(id_taskForm); return(taskForm); }