public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Brand,Mildness,ProductionDate")] Mayo mayo) { if (id != mayo.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(mayo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MayoExists(mayo.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(mayo)); }
public AddOrder(Customer customer) { InitializeComponent(); ACustomer = customer; Coffee aCoffee = new Coffee(); CoffeeDarkRoast aDarkRoastCoffee = new CoffeeDarkRoast(); SandwichWithBacon aBaconSandwich = new SandwichWithBacon(); SandwichWithEggSalad aEggSandwich = new SandwichWithEggSalad(); SandwichWithRoastedBeef aRoastBeefSandwich = new SandwichWithRoastedBeef(); Tea aTea = new Tea(); Milk aMilk = new Milk(); Suggar aSuggar = new Suggar(); Sweetener aSweetner = new Sweetener(); Cheese aCheese = new Cheese(); Mayo aMayo = new Mayo(); Lettuce aLettuce = new Lettuce(); Tomato aTomato = new Tomato(); lbxOrders.Items.Add(aCoffee); lbxOrders.Items.Add(aDarkRoastCoffee); lbxOrders.Items.Add(aBaconSandwich); lbxOrders.Items.Add(aEggSandwich); lbxOrders.Items.Add(aRoastBeefSandwich); lbxOrders.Items.Add(aTea); lbxAdditions.Items.Add(aSweetner); lbxAdditions.Items.Add(aMilk); lbxAdditions.Items.Add(aSuggar); lbxAdditions.Items.Add(aCheese); lbxAdditions.Items.Add(aMayo); lbxAdditions.Items.Add(aLettuce); lbxAdditions.Items.Add(aTomato); }
public void Delete(int Id) { Mayo mayo = Get(Id); _DBContext.Mayos.Remove(mayo); _DBContext.SaveChanges(); }
public void Put(Mayo dbEntity, Mayo entity) { dbEntity.Name = entity.Name; dbEntity.Brand = entity.Brand; dbEntity.Mildness = entity.Mildness; dbEntity.ProductionDate = entity.ProductionDate; _DBContext.Update(dbEntity); _DBContext.SaveChanges(); }
public IActionResult Post([FromBody] Mayo mayo) { if (mayo == null) { return(BadRequest("Mayo is null")); } _mayoService.Post(mayo); return(Ok()); }
public async Task <IActionResult> Create([Bind("Id,Name,Brand,Mildness,ProductionDate")] Mayo mayo) { if (ModelState.IsValid) { _context.Add(mayo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(mayo)); }
public IActionResult Delete(int id) { Mayo mayo = _mayoService.Get(id); if (mayo == null) { return(NotFound("Couldn't find the record")); } _mayoService.Delete(id); return(NoContent()); }
static void Main(string[] args) { var myTomato = new Tomato(VeggieColor.Red); var mySourdough = new Sourdough(MoistureLevel.Moist, TextureType.Fluffy); var myChicken = new Chicken(Meats.MeatTexture.Tender, Meats.MeatCut.Shredded); var myMayo = new Mayo(FlavorType.Creamy, AmountType.Extra); var mySandwich = new Sandwich(mySourdough, myChicken, myTomato, myMayo); mySandwich.OrderSandwich(); Console.ReadLine(); }
public IActionResult Put(int id, [FromBody] Mayo mayo) { if (mayo == null) { return(BadRequest("Ketchup is null")); } Mayo mayoToUpdate = _mayoService.Get(id); if (mayoToUpdate == null) { return(NotFound("Could not find the record")); } _mayoService.Put(mayoToUpdate, mayo); return(NoContent()); }
public void AddAnOrder(IMenuItem aItem) { AMenuItemAddition = lbxAdditions.SelectedItem as MenuItemAddition; if (AMenuItemAddition is Suggar) { CurrentOrder = new Suggar(aItem); lbxOrdered.Items.Clear(); lbxOrdered.Items.Add(CurrentOrder); } else if (AMenuItemAddition is Milk) { CurrentOrder = new Milk(aItem); lbxOrdered.Items.Clear(); lbxOrdered.Items.Add(CurrentOrder); } else if (AMenuItemAddition is Sweetener) { CurrentOrder = new Sweetener(aItem); lbxOrdered.Items.Clear(); lbxOrdered.Items.Add(CurrentOrder); } else if (AMenuItemAddition is Lettuce) { CurrentOrder = new Lettuce(aItem); lbxOrdered.Items.Clear(); lbxOrdered.Items.Add(CurrentOrder); } else if (AMenuItemAddition is Tomato) { CurrentOrder = new Tomato(aItem); lbxOrdered.Items.Clear(); lbxOrdered.Items.Add(CurrentOrder); } else if (AMenuItemAddition is Cheese) { CurrentOrder = new Cheese(aItem); lbxOrdered.Items.Clear(); lbxOrdered.Items.Add(CurrentOrder); } else if (AMenuItemAddition is Mayo) { CurrentOrder = new Mayo(aItem); lbxOrdered.Items.Clear(); lbxOrdered.Items.Add(CurrentOrder); } }
private void BtnAdd_Click(object sender, EventArgs e) { if (menuGridView.CurrentRow == null) { return; } IMenuItem item = new Coffee(); if (menuGridView.CurrentRow.Index == 1) { item = new CoffeeDarkRoast(); } else if (menuGridView.CurrentRow.Index == 2) { item = new Tea(); } else if (menuGridView.CurrentRow.Index == 3) { item = new SandwichWithBacon(); } else if (menuGridView.CurrentRow.Index == 4) { item = new SandwichWithEggSalad(); } else if (menuGridView.CurrentRow.Index == 5) { item = new SandwichWithRoastedBeef(); } for (int i = 0; i < NUD_Cheese.Value; i++) { item = new Cheese(item); } for (int i = 0; i < NUD_Lettuce.Value; i++) { item = new Lettuce(item); } for (int i = 0; i < NUD_Mayo.Value; i++) { item = new Mayo(item); } for (int i = 0; i < NUD_Milk.Value; i++) { item = new Milk(item); } for (int i = 0; i < NUD_Sugar.Value; i++) { item = new Suggar(item); } for (int i = 0; i < NUD_Sweetener.Value; i++) { item = new Sweetener(item); } for (int i = 0; i < NUD_Tomato.Value; i++) { item = new Tomato(item); } orderListGridView.Rows.Add(); orderListGridView.Rows[numberOfRows].Cells[0].Value = item.Description; orderListGridView.Rows[numberOfRows++].Cells[1].Value = item.Cost; items.Add(item); }
public void Post(Mayo mayo) { _DBContext.Add(mayo); _DBContext.SaveChanges(); }