public async Task <ShoppingListModel> CreateShoppingListFromTemplate(IdModel templateId, CancellationToken cancellationToken) { var shoppingTemplate = await shoppingTemplateRepository.GetTemplate(templateId, cancellationToken); var shoppingList = new ShoppingListModel { Title = $"{shoppingTemplate.Title} - {clock.UtcNow:yyyy.MM.dd}", Items = shoppingTemplate.Items.Select(x => new ShoppingItemModel { Id = x.Id, Title = x.Title, Quantity = x.Quantity, Comment = x.Comment, }).ToList(), }; await shoppingListRepository.CreateShoppingList(shoppingList, cancellationToken); return(shoppingList); }
public Task <ShoppingTemplateModel> GetTemplate(IdModel templateId, CancellationToken cancellationToken) { return(repository.GetTemplate(templateId, cancellationToken)); }