private decimal CalculateTotalCost(int?size, int?crust) { var sizeCost = _sizeRepo.GetSizes(size).FirstOrDefault().SizeCost; var crustCost = _crustRepo.GetCrustTypes(crust).FirstOrDefault().CrustCost; return(sizeCost + crustCost); }
public void ViewUserOrderHistory() { if (orderRepo != null) { foreach (var order in orderRepo.GetOrders(userId: currentUser.UserId)) { var storeId = order.StoreId ?? default(int); foreach (var pizza in pizzaSoldRepo.GetPizzasSold(orderId: order.OrderId)) { var pizzaSize = pizza.PizzaSize ?? default(int); var pizzaCrust = pizza.PizzaCrust ?? default(int); Console.WriteLine($"{order.OrderId}: {sizeRepo.GetSizes(pizzaSize).First().SizeName}" + $" {pizza.PizzaName} " + $"with {crustRepo.GetCrustTypes(pizzaCrust).First().CrustName} crust - ${pizza.TotalCost} "); } Console.WriteLine($"{storeRepo.GetStores(storeId).First().StoreLocation} - {order.OrderTimestamp}"); } } else { throw new NullReferenceException("ERROR: Order history not found"); } }