public async Task <ResponseEntity> updateStatusTask(UpdateStatusVM statusTask, string token) { UserJira user = _userService.getUserByToken(token).Result; var task = _taskRepository.GetSingleByConditionAsync("taskId", statusTask.taskId).Result; List <KeyValuePair <string, dynamic> > columns = new List <KeyValuePair <string, dynamic> >(); columns.Add(new KeyValuePair <string, dynamic>("taskId", task.taskId)); //columns.Add(new KeyValuePair<string, dynamic>("userId", user.id)); if (task == null) { return(new ResponseEntity(StatusCodeConstants.NOT_FOUND, "task is not found!", MessageConstants.MESSAGE_ERROR_404)); } var projectUser = _taskUserRepository.GetMultiByListConditionAndAsync(columns).Result; //if(projectUser.Count() == 0) //{ // return new ResponseEntity(StatusCodeConstants.NOT_FOUND, "user is not assign!", MessageConstants.MESSAGE_ERROR_404); //} task.statusId = statusTask.statusId; await _taskRepository.UpdateAsync("taskId", task.taskId, task); return(new ResponseEntity(StatusCodeConstants.OK, "Update task successfully!", MessageConstants.MESSAGE_SUCCESS_200)); }
public async Task <ResponseEntity> deleteUser(int id) { try { var userEdit = _useJiraRepository.GetSingleByConditionAsync("id", id).Result; if (userEdit == null) { return(new ResponseEntity(StatusCodeConstants.NOT_FOUND, MessageConstants.DELETE_ERROR, MessageConstants.MESSAGE_ERROR_404)); } List <KeyValuePair <string, dynamic> > columns = new List <KeyValuePair <string, dynamic> >(); columns.Add(new KeyValuePair <string, dynamic>("userId", userEdit.id)); var lstUserProject = _project_userRepository.GetMultiByListConditionAndAsync(columns).Result; var lstTask = _taskUserRepository.GetMultiByListConditionAndAsync(columns).Result; var lstComment = _taskUserRepository.GetMultiByListConditionAndAsync(columns).Result; List <KeyValuePair <string, dynamic> > columns1 = new List <KeyValuePair <string, dynamic> >(); columns1.Add(new KeyValuePair <string, dynamic>("creator", userEdit.id)); var project = _projectRepository.GetMultiByListConditionAndAsync(columns1).Result; if (project.Count() > 0) { return(new ResponseEntity(StatusCodeConstants.BAD_REQUEST, "Người dùng đã tạo project không thể xoá được !", MessageConstants.MESSAGE_ERROR_400)); } List <dynamic> lstResult = new List <dynamic>(); foreach (var item in lstTask) { lstResult.Add(item.id); } await _taskUserRepository.DeleteByIdAsync(lstResult); List <dynamic> lstResult1 = new List <dynamic>(); foreach (var item in lstUserProject) { lstResult1.Add(item.id); } await _project_userRepository.DeleteByIdAsync(lstResult1); List <dynamic> lstResult2 = new List <dynamic>(); foreach (var item in lstComment) { lstResult2.Add(item.id); } await _commentRepository.DeleteByIdAsync(lstResult2); List <dynamic> lstId = new List <dynamic>(); lstId.Add(id); await _useJiraRepository.DeleteByIdAsync(lstId); return(new ResponseEntity(StatusCodeConstants.OK, MessageConstants.DELETE_SUCCESS, MessageConstants.MESSAGE_SUCCESS_200)); }catch (Exception err) { return(new ResponseEntity(StatusCodeConstants.BAD_REQUEST, MessageConstants.DELETE_ERROR, MessageConstants.MESSAGE_ERROR_400)); } }