Exemplo n.º 1
0
        public async Task Update(int workItemId, WorkItemDto workItemDto)
        {
            var oldWorkItem = await GetHistoryById(workItemId);

            var workItem = _mapper.Map <WorkItemDto, WorkItem>(workItemDto);

            await _workItemRepository.Update(workItemId, workItem);

            var newWorkItem = await GetHistoryById(workItemId);

            await AttachFilesToWorkItem(workItemDto.Files, workItemId);

            await _bus.Publish(new WorkItemUpdated
            {
                WorkItemId  = workItemId,
                OldWorkItem = oldWorkItem,
                NewWorkItem = newWorkItem
            });
        }
Exemplo n.º 2
0
        public List <WorkItemDto> Sync(int weekId, List <WorkItemDto> workItems, string userId)
        {
            List <WorkItemDto> currentTaskList = new List <WorkItemDto>();

            foreach (WorkItemDto item in workItems)
            {
                WorkItemDto workItem = GetWorkItemById(item.TaskId, item.ServerId, userId);
                if (workItem == null)
                {
                    AddWorkItem(workItem, userId);
                }
                else
                {
                    if (!workItem.Equals(item, out bool isUpdated) && isUpdated)
                    {
                    }
                }
            }
            return(currentTaskList);
        }
Exemplo n.º 3
0
        public async Task <WorkItemDto> Create(WorkItemDto workItemDto)
        {
            var workItemEntity = _mapper.Map <WorkItemDto, WorkItem>(workItemDto);

            var workItem = await _workItemRepository.Create(workItemEntity);

            if (workItemDto.Files != null)
            {
                await AttachFilesToWorkItem(workItemDto.Files, workItemEntity.WorkItemId);
            }

            var newWorkItemDto = _mapper.Map <WorkItem, WorkItemHistoryDto>(workItem);
            await _bus.Publish(new WorkItemCreated
            {
                WorkItemId  = workItem.WorkItemId,
                NewWorkItem = newWorkItemDto
            });

            return(_mapper.Map <WorkItem, WorkItemDto>(workItem));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> SaveWorkItem(WorkItemDto workItem)
        {
            if (User.RoleInPatrol(workItem.PatrolId).CanMaintainWorkItems())
            {
                if (workItem.Id != default(int))
                {
                    var existing = await _workItemService.GetWorkItem(workItem.Id);

                    if (!User.RoleInPatrol(existing.PatrolId).CanMaintainWorkItems())
                    {
                        return(Forbid());
                    }
                }
                await _workItemService.SaveWorkItem(workItem, User.UserId());

                return(Ok());
            }
            else
            {
                return(Forbid());
            }
        }
Exemplo n.º 5
0
        public static WorkItemDto ToDto(this UserWorkItem userWorkItem, int id)
        {
            WorkItemDto dto = new WorkItemDto
            {
                Id             = id,
                TaskId         = userWorkItem.TaskId,
                UserId         = userWorkItem.UserId,
                WeekId         = userWorkItem.WeekId,
                Title          = userWorkItem.Title,
                Description    = userWorkItem.Description,
                Sprint         = userWorkItem.Sprint,
                Project        = userWorkItem.Project,
                TotalHours     = userWorkItem.TotalHours,
                WeekHours      = userWorkItem.WeekHours,
                Status         = userWorkItem.Status,
                ServerId       = userWorkItem.ServerId,
                Comments       = userWorkItem.Comments,
                EstimatedHours = userWorkItem.EstimatedHours,
                AssignedTo     = userWorkItem.AssignedTo
            };

            if (userWorkItem.StartDate != null)
            {
                dto.StartDate = userWorkItem.StartDate.Value.ToString(Constants.DATE_FORMAT);
            }

            if (userWorkItem.EndDate != null)
            {
                dto.EndDate = userWorkItem.EndDate.Value.ToString(Constants.DATE_FORMAT);
            }

            if (userWorkItem.ETA != null)
            {
                dto.ETA = userWorkItem.ETA.Value.ToString(Constants.DATE_FORMAT);
            }
            return(dto);
        }
Exemplo n.º 6
0
        public static WorkItemDtoCollection GetWorkItemsFromTeamBuilds(this TfsConfigurationServer tfsConfigurationServer, Guid teamProjectCollectionId, Uri[] teamBuildUris)
        {
            if (tfsConfigurationServer == null)
            {
                throw new ArgumentNullException("tfsConfigurationServer");
            }

            TfsTeamProjectCollection tfsTeamProjectCollection = tfsConfigurationServer.GetTeamProjectCollection(teamProjectCollectionId);
            IBuildServer             buildServer   = tfsTeamProjectCollection.GetService <IBuildServer>();
            WorkItemStore            workItemStore = tfsTeamProjectCollection.GetService <WorkItemStore>();

            IBuildDetail[] buildDetails             = buildServer.QueryBuildsByUri(teamBuildUris, new[] { InformationTypes.AssociatedWorkItem }, QueryOptions.Definitions);
            Dictionary <int, WorkItemDto> workItems = new Dictionary <int, WorkItemDto>();

            foreach (IBuildDetail buildDetail in buildDetails)
            {
                List <IWorkItemSummary> workItemSummaries = InformationNodeConverters.GetAssociatedWorkItems(buildDetail);
                foreach (IWorkItemSummary workItemSummary in workItemSummaries)
                {
                    if (!workItems.ContainsKey(workItemSummary.WorkItemId))
                    {
                        WorkItem    workItem    = workItemStore.GetWorkItem(workItemSummary.WorkItemId);
                        WorkItemDto workItemDto = WorkItemDto.CreateFromWorkItem(workItem, buildDetail.BuildNumber);
                        workItems.Add(workItem.Id, workItemDto);
                    }
                }
            }

            WorkItemDtoCollection workItemDtoCollection = new WorkItemDtoCollection();

            foreach (KeyValuePair <int, WorkItemDto> keyValuePair in workItems)
            {
                workItemDtoCollection.Add(keyValuePair.Value);
            }

            return(workItemDtoCollection);
        }
        public WorkItemDto FindWorkItemFromServer(int taskid, int serverId, int weekId, string userId)
        {
            WorkItemDto workItemDto = null;
            TeamServer  server      = null;

            using (TeamServerRepository teamServerRepository = new TeamServerRepository())
            {
                server = teamServerRepository.FindLocal(x => x.Id == serverId);
                if (server == null)
                {
                    _logger.Error("Server not found with id " + serverId);
                    throw new Exception("Server not found.");
                }
            }
            string         serverUrl  = server.Url;
            UserServerInfo userServer = null;

            using (UserServerInfoRepository userServerInfoRepository = new UserServerInfoRepository())
            {
                userServer = userServerInfoRepository.Find(x => x.TfsId == serverId && x.UserId == userId);
                if (userServer == null)
                {
                    throw new Exception(string.Format("User {0} not registered to server {1}", userId, serverId));
                }
            }
            WorkItem workItem = _teamServerManagementService.GetWorkItemById(taskid, serverUrl, userServer.CredentialHash);

            if (workItem != null)
            {
                workItemDto          = workItem.ToEntity(serverId).ToDto(-1);
                workItemDto.WeekId   = weekId;
                workItemDto.ServerId = serverId;
                workItemDto.TaskId   = taskid;
            }
            return(workItemDto);
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Put(int id, WorkItemDto workItemDto)
        {
            await _workItemService.Update(id, workItemDto);

            return(NoContent());
        }
Exemplo n.º 9
0
 public bool UpdateWorkItem(WorkItemDto dto, string userId)
 {
     return(false);
 }
        public async Task <IActionResult> GetAll([FromRoute] Guid id, [FromBody] WorkItemDto workItem)
        {
            var result = await _repository.UpdateEntity(id, _mapper.Map <WorkItem>(workItem));

            return(Ok(MapEntity(result)));
        }
 public WorkItemDto UpdateWorkItem(WorkItemDto workItemDto)
 {
     return(_workItemManager.UpdateWorkItem(workItemDto));
 }