コード例 #1
0
        public List <ApplicationUser> GetUsersForEventNotification(WorkEvent @event)
        {
            var userIds = new List <ApplicationUser>();

            switch (@event.Type)
            {
            case EventType.WorkItemChanged:
            case EventType.WorkItemStateChanged:
            case EventType.WorkItemAdded:
            case EventType.WorkItemDeleted:
            case EventType.WorkItemCommentAdded:
                // ReSharper disable once PossibleInvalidOperationException
                // Проверяется перед вызовом метода
                var workItem = _workItemRepository.GetByIdNoTracking(@event.ObjectId.Value);
                return(GetResponsibleUsers(workItem).Distinct(new ApplicationUserEqualityComparer()).ToList());

            case EventType.WorkItemAppointed:
            case EventType.WorkItemDisappointed:
                return(new List <ApplicationUser> {
                    _usersService.Get(@event.Data)
                });

            case EventType.User:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(userIds);
        }
コード例 #2
0
        public WorkItem GetWithNoTracking(int id)
        {
            var workItem = _repository.GetByIdNoTracking(id);

            if (workItem == null)
            {
                throw new PmsException(string.Format(Resources.WorkItemNotFound, id));
            }
            return(workItem);
        }
コード例 #3
0
        public async Task <WorkItemHistoryDto> GetHistoryById(int workItemId)
        {
            var workItem = await _workItemRepository.GetByIdNoTracking(workItemId);

            return(_mapper.Map <WorkItem, WorkItemHistoryDto>(workItem));
        }