public async Task <IActionResult> NewCode(long id) { var itemGroup = await _itemGroupRepo.GetAsync(id); if (itemGroup == null) { return(NotFound(Resources.Items.ItemResource.ItemGroupNotFound)); } var newCode = await _itemRepo.GetNewCodeAsync(itemGroup.Id); return(Ok(newCode)); }
public async Task <ItemGroupDto> GetAsync(Guid groupId, bool includeTasks = true) { var userId = _currentUserService.GetCurrentUser().Id; var group = await _itemGroupRepository.GetAsync(userId, groupId); if (group is null) { throw new GroupIdInvalidException(); } var taskDtos = new List <TaskDto>(); if (includeTasks) { var tasks = await _taskRepository.GetTasksInGroupAsync(groupId); foreach (var taskEntity in tasks) { taskDtos.Add(new TaskDto(taskEntity.Id, taskEntity.Name, taskEntity.Created, taskEntity.IsComplete, taskEntity.GroupId)); } } var groupDto = new ItemGroupDto(group.Id, group.Name, group.Description, group.ImageUri, taskDtos); return(groupDto); }
public async Task <IActionResult> NewCode(long?id) { Guid?parentId = null; if (id.HasValue) { var costCenter = await _itemGroupRepo.GetAsync(id.Value); if (costCenter == null) { return(NotFound(Resources.Items.ItemResource.ItemGroupNotFound)); } parentId = costCenter.Id; } var newCode = await _itemGroupRepo.GetNewCodeAsync(parentId); return(Ok(newCode)); }