Ejemplo n.º 1
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));
        }