private async Task <TrolleyViewModel> CreateTrolleyViewModelFromTrolleyAsync(Trolley trolley) { var trolleyViewModel = new TrolleyViewModel { Id = trolley.Id, OwnerId = trolley.OwnerId }; foreach (var trolleyItem in trolley.Items) { var trolleyItemViewModel = new TrolleyItemViewModel { Id = trolleyItem.Id, CatalogItemId = trolleyItem.CatalogItemId, Quantity = trolleyItem.Quantity }; var catalogItem = await _catalogItemRepository.GetAsync(trolleyItem.CatalogItemId); trolleyItemViewModel.ProductId = catalogItem.ProductId; trolleyItemViewModel.ProductName = catalogItem.ProductName; trolleyItemViewModel.ProductPictureUrl = catalogItem.ProductPictureUrl; trolleyViewModel.Items.Add(trolleyItemViewModel); } return(trolleyViewModel); }
private async Task <TrolleyViewModel> CreateTrolleyViewModelFromTrolleyAsync(Trolley trolley) { var trolleyViewModel = new TrolleyViewModel { Id = trolley.Id, OwnerId = trolley.OwnerId }; foreach (var trolleyItem in trolley.Items) { var trolleyItemViewModel = new TrolleyItemViewModel { Id = trolleyItem.Id, CatalogItemId = trolleyItem.CatalogItemId, Quantity = trolleyItem.Quantity }; var catalogItem = await _catalogItemRepository.GetAsync(trolleyItem.CatalogItemId); var newItem = _manager.GetIndustry().ConvertItem(catalogItem); trolleyItemViewModel.ProductId = newItem.ProductId; trolleyItemViewModel.ProductName = newItem.ProductName; trolleyItemViewModel.ProductPictureUrl = newItem.ProductPictureUrl; trolleyItemViewModel.ProductAllergyInfo = newItem.ProductAllergyInfo; trolleyViewModel.Items.Add(trolleyItemViewModel); } return(trolleyViewModel); }