public Pizza() { size = PizzaSize.small; cheese = 0; pepperoni = 0; ham = 0; }
public IHttpActionResult PutPizzaSize(string id, PizzaSize pizzaSize) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != pizzaSize.SizeName) { return(BadRequest()); } db.Entry(pizzaSize).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PizzaSizeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void PrepararPizzaSemBorda(IPizzaBuilder pizzaBuilder, PizzaSize pizzaSize) { pizzaBuilder.PreparaMassa(pizzaSize); pizzaBuilder.InsereIngradientes(); pizzaBuilder.TempoForno(); pizzaBuilder.DefineValor(); }
public IHttpActionResult PostPizzaSize(PizzaSize pizzaSize) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.PizzaSizes.Add(pizzaSize); try { db.SaveChanges(); } catch (DbUpdateException) { if (PizzaSizeExists(pizzaSize.SizeName)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = pizzaSize.SizeName }, pizzaSize)); }
private PizzaModel AddPizzaOrder(string id, string size, BotUserState userState) { PizzaModel pizzaModelFind = userState.OrderModel.Pizzas.Where(x => x.PizzaId == int.Parse(id) && x.SizeName == size).FirstOrDefault(); if (pizzaModelFind != null) { pizzaModelFind.Quantity++; userState.OrderModel.PriceTotal += pizzaModelFind.Price; return(pizzaModelFind); } else { Pizza pizza = context.Pizzas.Where(x => x.PizzaId == int.Parse(id)).FirstOrDefault(); PizzaSize pizzaSize = context.Pizzas.Include(x => x.PizzaIngredients).ThenInclude(y => y.Ingredient) .Include(x => x.PizzaSizes).ThenInclude(y => y.SizeP).FirstOrDefault().PizzaSizes.Where(x => x.SizeP.Size == size).FirstOrDefault(); PizzaModel pizzaModel = new PizzaModel { PizzaId = pizza.PizzaId, PizzaName = pizza.Name, SizeId = pizzaSize.SizePId, SizeName = pizzaSize.SizeP.Size, Quantity = 1, Price = pizzaSize.Price }; userState.OrderModel.Pizzas.Add(pizzaModel); userState.OrderModel.PriceTotal += (pizzaModel.Quantity * pizzaModel.Price); return(pizzaModel); } }
private static PizzaSizeMetadata GetMetadata(PizzaSize ps) { var info = ps.GetType().GetMember(ps.ToString()); var attributes = info[0].GetCustomAttributes(typeof(PizzaSizeMetadata), false); return(attributes.Length > 0 ? attributes[0] as PizzaSizeMetadata : new PizzaSizeMetadata()); }
public Pizza(PizzaSize size, int cheese, int pepperoni, int ham) { this.size = size; SetCheese(cheese); SetPepperoni(pepperoni); SetHam(ham); }
public IActionResult Save(PizzaSizeViewModel pizzaSize) { if (pizzaSize == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(View("Edit", pizzaSize)); } PizzaSize existingPizzaSize = Data.PizzaSizes.FirstOrDefault(x => x.Id == pizzaSize.Id); if (existingPizzaSize == null) { PizzaSize newPizzaSize = new PizzaSize(pizzaSize.PizzaId, pizzaSize.SizeId, pizzaSize.Price); Data.PizzaSizes.Add(newPizzaSize); return(RedirectToAction("Index")); } int index = Data.PizzaSizes.IndexOf(existingPizzaSize); Data.PizzaSizes.RemoveAt(index); existingPizzaSize.PizzaId = pizzaSize.PizzaId; existingPizzaSize.Pizza = Data.Pizzas.FirstOrDefault(x => x.Id == pizzaSize.PizzaId); existingPizzaSize.SizeId = pizzaSize.SizeId; existingPizzaSize.Size = Data.Sizes.FirstOrDefault(x => x.Id == pizzaSize.SizeId); existingPizzaSize.Price = pizzaSize.Price; Data.PizzaSizes.Add(existingPizzaSize); return(RedirectToAction("Index")); }
public IActionResult Add(PizzaSize pizza) { var newPizzaSize = new PizzaSize(pizza.Pizza, pizza.Size, pizza.Price); StaticDatabase.PizzaSizes.Add(newPizzaSize); return(StatusCode(StatusCodes.Status201Created, $"You add your {pizza.Pizza.Name} pizza")); }
/// <summary> /// Basic Pizza choice has no pizza with default pizza /// constructor. /// </summary> public Pizza() { toppings = new List <Toppings>(); pizzaSize = PizzaSize.twelveInch; crust = Crust.thin; //defaultToppings(); }
public async Task <IActionResult> PutPizzaSize([FromRoute] int id, [FromBody] PizzaSize pizzaSize) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != pizzaSize.ID) { return(BadRequest()); } _context.Entry(pizzaSize).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PizzaSizeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void PreparaMassa(PizzaSize pizzaSize) { this.Init(); this.Pizza.PizzaType = PizzaType.Salgada; this.Pizza.PizzaSize = pizzaSize; }
public ActionResult DeleteConfirmed(int id) { PizzaSize pizzaSize = db.PizzaSizes.Find(id); db.PizzaSizes.Remove(pizzaSize); db.SaveChanges(); return(RedirectToAction("Index")); }
public Pizza(PizzaSize size, PizzaFlavor flavor, List <PizzaCustomization> customizations = null) { Size = size; Flavor = flavor; Customizations = customizations ?? new List <PizzaCustomization>(); CalculatePriceAndEstimatedTime(); }
public Pizza(int pizzaID, string name, PizzaSize size, PizzaDough dough, PizzaSauce sauce) { PizzaID = pizzaID; Name = name; Size = size; Dough = dough; Sauce = sauce; }
public Pizza(int pizzaID, string name, PizzaSize size, PizzaDough dough, PizzaSauce sauce) { this.PizzaID = pizzaID; this.Name = name; this.Size = size; this.Dough = dough; this.Sauce = sauce; }
public Pizza(int pizzaID, string name, PizzaSize size, PizzaDough dough, PizzaSauce sauce, ObservableCollection <Topping> toppings) { this.PizzaID = pizzaID; this.Name = name; this.Size = size; this.Dough = dough; this.Sauce = sauce; this.Toppings = toppings; }
public Pizza() { pizzaSize = PizzaSize.medium; pepperoni = false; mushrooms = false; pineapple = false; Crust = PizzaCrust.thick; }
//The PizzaType is used for pricing and so is combination of crust, size, base, etc. public static PizzaType GetPizzaType(PizzaSize size, PizzaCrust crust, PizzaBase pizzaBase = PizzaBase.Regular) { switch (pizzaBase) { case PizzaBase.Regular: break; case PizzaBase.Pesto: case PizzaBase.White: if (crust == PizzaCrust.SatchPan) { return(PizzaType.PestoWhitePan); } else if (size == PizzaSize.Medium) { return(PizzaType.PestoWhiteMedium); } else if (size == PizzaSize.Large) { return(PizzaType.PestoWhiteLarge); } break; } switch (size) { case PizzaSize.Indy: return(PizzaType.Indy); case PizzaSize.Slice: if (crust == PizzaCrust.RegularThin) { return(PizzaType.ThinSlice); } else { return(PizzaType.PanSlice); } case PizzaSize.Medium: return(PizzaType.Medium); case PizzaSize.Large: return(PizzaType.Large); } switch (crust) { case PizzaCrust.Calzone: return(PizzaType.Calzone); case PizzaCrust.Mfp: return(PizzaType.Mfp); case PizzaCrust.SatchPan: return(PizzaType.SatchPan); } return(PizzaType.None); }
public PizzaClass(PizzaSize size, HashSet <string> ingrediants) { Size = size; foreach (string item in ingrediants) { Ingrediants.Add(item); } UpdatePrice(); }
public Pizza(PizzaSize size, PizzaCrust crust) { this.Name = "Pizza"; this.SizeOfPizza = size; this.Crust = crust; CalculateCost(); }
public APizzaSize Map(PizzaSize pizzaSize) { return(new APizzaSize { PizzaSizeId = pizzaSize.PizzaSizeId, PizzaSizeName = pizzaSize.PizzaSizeName, PizzaSizeInches = pizzaSize.PizzaSizeInches, PizzaSizePrice = pizzaSize.PizzaSizePrice }); }
public Size Map(PizzaSize size) { return(new Size { Id = size.Id, size = size.Size, Price = size.Price // PizzaToppings = topping.PizzaToppings.Select(x => Map(x)).ToList() }); }
public With(string customerName, PizzaSize size) { if (customerName.IsNullOrEmpty()) { AddDomainException("Customer name empty"); } instance.CustomerName = customerName; instance.Size.Value = size; }
public static string GetDescription(this PizzaSize pizzaSize) { return(pizzaSize switch { PizzaSize.Small => "pequeña", PizzaSize.Medium => "mediana", PizzaSize.Large => "grande", PizzaSize.Undefined => string.Empty, _ => "desconocida" });
private void Test_PizzaSizeExists() { var sut = new PizzaSize(); PizzaSize sut1 = new PizzaSize(); var actual = sut; Assert.IsType <PizzaSize>(actual); Assert.NotNull(actual); }
public ActionResult Edit([Bind(Include = "PizzaId,PizzaSizes,PizzaPrice")] PizzaSize pizzaSize) { if (ModelState.IsValid) { db.Entry(pizzaSize).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pizzaSize)); }
public IActionResult Save(OrderItemViewModel orderItem) { if (orderItem == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(View("Add", orderItem)); } Customer customer = Data.Customers.FirstOrDefault(x => x.Orders.Any(y => y.Id == orderItem.OrderId)); if (customer == null) { return(NotFound()); } Order order = customer.Orders.FirstOrDefault(x => x.Id == orderItem.OrderId); if (order == null) { return(NotFound()); } PizzaSize pizzaSize = Data.PizzaSizes.FirstOrDefault(x => x.Id == orderItem.PizzaSizeId); if (pizzaSize == null) { return(NotFound()); } OrderItem existingOrderItemForSamePizza = order.OrderItems.FirstOrDefault(x => x.PizzaSizeId == orderItem.PizzaSizeId); if (existingOrderItemForSamePizza != null) { int indexOfExistingOrderItem = order.OrderItems.IndexOf(existingOrderItemForSamePizza); order.OrderItems.RemoveAt(indexOfExistingOrderItem); existingOrderItemForSamePizza.Quantity += orderItem.Quantity; order.OrderItems.Add(existingOrderItemForSamePizza); } else { OrderItem newOrderItem = new OrderItem(pizzaSize, orderItem.Quantity, order.Id); order.OrderItems.Add(newOrderItem); } return(RedirectToAction("Details", "Order", new { order.Id })); }
public ActionResult Create([Bind(Include = "PizzaId,PizzaSizes,PizzaPrice")] PizzaSize pizzaSize) { if (ModelState.IsValid) { db.PizzaSizes.Add(pizzaSize); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pizzaSize)); }
public IHttpActionResult GetPizzaSize(string id) { PizzaSize pizzaSize = db.PizzaSizes.Find(id); if (pizzaSize == null) { return(NotFound()); } return(Ok(pizzaSize)); }
public Pizza(PizzaSize size) { Size = size; }