public async Task <ResponseEntity> getAll(int?id = 0) { var lstResult = await _priorityRepository.GetMultiByConditionAsync("priorityId", id); if (lstResult.Count() == 0) { lstResult = await _priorityRepository.GetAllAsync(); } return(new ResponseEntity(StatusCodeConstants.OK, lstResult, MessageConstants.MESSAGE_SUCCESS_200)); }
public async Task <List <PriorityListViewModel> > Handle(GetAllPriorityQuery request, CancellationToken cancellationToken) { var priorities = await _priorityRepository.GetAllAsync(); var prioritiesListViewModel = priorities.Select(priority => new PriorityListViewModel { Id = priority.Id, Name = priority.Name, Color = priority.Color, }).ToList(); return(prioritiesListViewModel); }
public async Task <ResponseEntity> getProjectById(int?idProject) { var pro = await _projectRepository.GetSingleByConditionAsync("id", idProject); if (pro == null) { return(new ResponseEntity(StatusCodeConstants.NOT_FOUND, "Project is not found", MessageConstants.MESSAGE_ERROR_404)); } var lstUser = _projectUserRepository.GetMultiByConditionAsync("projectId", idProject).Result; List <Repository.Models.Member> members = new List <Repository.Models.Member>(); foreach (var item in lstUser) { var user = _userJira.GetSingleByConditionAsync("id", item.userId).Result; Repository.Models.Member mem = new Repository.Models.Member(); mem.userId = user.id; mem.name = user.name; mem.avatar = user.avatar; members.Add(mem); } ProjectCategory projectCategory = await _projectCategoryRepository.GetSingleByConditionAsync("id", pro.categoryId); ProjectDetail projectDetail = new ProjectDetail(); projectDetail.alias = pro.alias; projectDetail.projectName = pro.projectName; projectDetail.projectCategory = new ProjectCategoryDetail() { id = projectCategory.id, name = projectCategory.projectCategoryName }; projectDetail.description = FuncUtilities.Base64Decode(pro.description); projectDetail.id = pro.id; projectDetail.projectName = pro.projectName; projectDetail.members = members; CreatorModel creator = new CreatorModel(); if (pro.id != null) { creator.id = pro.creator; creator.name = _userJira.GetSingleByIdAsync(pro.creator).Result.name; } projectDetail.creator = creator; //List<ProjectDetail> lstResult = new List<ProjectDetail>(); var lstStatus = await _statusRepository.GetAllAsync(); //Lấy list priority IEnumerable <Priority> lstPriority = await _priorityRepository.GetAllAsync(); //Lấy list task var lstTask = await _taskRepository.GetAllAsync(); foreach (var status in lstStatus) { var statusTask = new StatusTask { statusId = status.statusId, statusName = status.statusName, alias = status.alias }; List <TaskDetail> task = lstTask.Where(n => n.projectId == projectDetail.id && n.statusId == status.statusId).Select(n => new TaskDetail { taskId = n.taskId, taskName = n.taskName, alias = n.alias, description = FuncUtilities.Base64Decode(n.description), statusId = n.statusId, priorityTask = getTaskPriority(n.priorityId, lstPriority), originalEstimate = n.originalEstimate, timeTrackingSpent = n.timeTrackingSpent, timeTrackingRemaining = n.timeTrackingRemaining, assigness = getListUserAsign(n.taskId).ToList(), taskTypeDetail = getTaskType(n.typeId), lstComment = getListComment(n.taskId).ToList(), projectId = n.projectId }).ToList(); statusTask.lstTaskDeTail.AddRange(task); projectDetail.lstTask.Add(statusTask); } return(new ResponseEntity(StatusCodeConstants.OK, projectDetail, MessageConstants.MESSAGE_SUCCESS_200)); }