public void Submit() { var discard = Pizzas.Where(p => !p.Done).ToList(); discard.ForEach(p => Pizzas.Remove(p)); this.Submitted = true; this.Points = this.GetTotal() * 0.25m; }
public bool Save() { try { int pizzaMaxId = Pizzas.Max(u => u.Id); int toppingMaxId = Toppings.Max(u => u.Id); int idIncrementer = 1; foreach (var np in Pizzas.Where(u => u.Id == 0)) { np.Id = pizzaMaxId + idIncrementer; idIncrementer++; } idIncrementer = 0; foreach (var nt in Toppings.Where(u => u.Id == 0)) { nt.Id = toppingMaxId + idIncrementer; idIncrementer++; } Helper.Serialize(Constants.DB_PIZZA_PATH, new DbPizza() { Pizzas = Pizzas }); Helper.Serialize(Constants.DB_TOPPING_PATH, new DbTopping() { Toppings = Toppings }); return(true); } catch (Exception ex) { return(false); } }
public void RemovePizza(int pizzaIdNumber) { if (Pizzas.ElementAt(pizzaIdNumber) != null) { // Remove pizza at index Pizzas.RemoveAt(pizzaIdNumber); // Remove all null pizzas from the order /* Clarification: If we just remove a pizza from the order, then that index will just be null. * This would cause some issues with the order count, since there would then be x-1 pizzas, but * the program would still just think there are x pizzas. Gotta be safe! */ Pizzas = Pizzas.Where(pizza => pizza != null).ToList(); foreach (var pizza in Pizzas) { pizza.PizzaID = Pizzas.IndexOf(pizza); } Value = RecalculateValue(); } else { Console.WriteLine("There are no pizzas in this order!"); } }
public IQueryable <Pizza> PricelessPizzass() { IQueryable <Pizza> pizzas = Pizzas.Where(p => p.Price == 0); return(pizzas); }
IQueryable <Pizza> IPizzaSharingContext.PricelessPizzass() { IQueryable <Pizza> pizzas = Pizzas.Where(p => p.Price == 0); return(pizzas); }