void PopulateOrders() { if (App.CheckoutItems == null) { return; } var foodItems = App.CheckoutItems.GroupBy(p => p.Id); foreach (var item in foodItems) { var food = item.FirstOrDefault(); if (food == null) { continue; } var order = new OrderDetail { FoodId = food.Id, FoodName = food.Name, Quantity = item.Count(), SellingPrice = food.PricePerQty, }; CheckoutItems.Add(new OrderDetailsViewModel(order, this)); } if (CheckoutItems.Count <= 0) { return; } TotalPrice = CheckoutItems.Sum(p => p.Details.TotalPrice); }
public void UpdateTotalPrice() { TotalPrice = CheckoutItems.Sum(p => p.Details.TotalPrice); CalculateDiscount(); }