public async Task <IActionResult> Edit(int id, [Bind("TastingId,TastingName")] Tasting tasting) { if (id != tasting.TastingId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tasting); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TastingExists(tasting.TastingId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tasting)); }
public ActionResult DeleteConfirmed(int id) { Tasting tasting = db.Tastings.Find(id); db.Tastings.Remove(tasting); db.SaveChanges(); return(RedirectToAction("Index")); }
public bool CreateTasting(TastingCreate model) { var beer = new Beer() { BeerName = model.BeerName, Style = model.Style, Cost = model.Cost, ABV = model.ABV, Vintage = model.Vintage, }; var brewery = new Brewery() { BreweryName = model.BreweryName, BrewLocCity = model.BrewLocCity, BrewLocState = model.BrewLocState, }; var ctx = new ApplicationDbContext(); ctx.Beers.Add(beer); ctx.Breweries.Add(brewery); ctx.SaveChanges(); var beerID = ctx.Beers.OrderByDescending(p => p.BeerID).FirstOrDefault().BeerID; var breweryID = ctx.Breweries.OrderByDescending(p => p.BreweryID).FirstOrDefault().BreweryID; var tasting = new Tasting() { BeerID = beerID, BeerName = model.BeerName, BreweryName = model.BreweryName, BreweryID = breweryID, DateOfTasting = model.DateOfTasting, DateAdded = DateTime.Now, Rating = model.Rating, Comment = model.Comment, }; { ctx.Tastings.Add(tasting); if (ctx.SaveChanges() == 1) { AverageRating(beer.BeerName); AverageBreweryRating(brewery.BreweryName); return(true); } return(false); } }
public async Task <IActionResult> Create([Bind("TastingId,TastingName")] Tasting tasting) { if (ModelState.IsValid) { _context.Add(tasting); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tasting)); }
public ActionResult Edit([Bind(Include = "TastingID,DrinkerID,BeerID,BreweryID,OwnerID,DateOfTasting,DateAdded,Rating,Comment")] Tasting tasting) { if (ModelState.IsValid) { db.Entry(tasting).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BeerID = new SelectList(db.Beers, "BeerID", "BeerName", tasting.BeerID); ViewBag.BreweryID = new SelectList(db.Breweries, "BreweryID", "BreweryName", tasting.BreweryID); return(View(tasting)); }
// GET: Tastings/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tasting tasting = db.Tastings.Find(id); if (tasting == null) { return(HttpNotFound()); } return(View(tasting)); }
// GET: Tastings/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tasting tasting = db.Tastings.Find(id); if (tasting == null) { return(HttpNotFound()); } ViewBag.BeerID = new SelectList(db.Beers, "BeerID", "BeerName", tasting.BeerID); ViewBag.BreweryID = new SelectList(db.Breweries, "BreweryID", "BreweryName", tasting.BreweryID); return(View(tasting)); }
public bool CreateTasting(TastingCreate model) { var entity = new Tasting() { OwnerId = _userId, TastingId = model.TastingId, TastingDate = model.TastingDate, Title = model.Title, Host = model.Host, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Tastings.Add(entity); return(ctx.SaveChanges() == 1); } }
public async Task <IActionResult> OnGetAsync(int?id) { if (!CheckAndReportAdmin()) { return(Page()); } if (id == null) { return(NotFound()); } Tasting = await _context.Tasting.FirstOrDefaultAsync(m => m.TastingId == id); if (Tasting == null) { return(NotFound()); } return(Page()); }
public TastingDetail GetTastingByID(int?tastingID) { using (var ctx = new ApplicationDbContext()) { Tasting entity = ctx.Tastings.SingleOrDefault(p => p.TastingID == tastingID); return(new TastingDetail { BeerName = entity.Beer.BeerName, BreweryName = entity.Brewery.BreweryName, Style = entity.Beer.Style, Cost = entity.Beer.Cost, ABV = entity.Beer.ABV, Vintage = entity.Beer.Vintage, Rating = entity.Rating, Comment = entity.Comment, }); } }
private void NerimanCombo_SelectedIndexChanged(object sender, EventArgs e) { if (NerimanCombo.Text == "Tasting 250CC") { NerimanOrder.Text = ""; Baverages tasting = new LeShokaladeNeriman(); tasting = new Tasting(tasting); NerimanOrder.Text = string.Format("Tadimlik Neriman-${0}", tasting.GetPrice() * Convert.ToDouble(NerimanUpdown.Value)); } if (NerimanCombo.Text == "Filling 400CC") { NerimanOrder.Text = ""; Baverages filling = new LeShokaladeNeriman(); filling = new Filling(filling); NerimanOrder.Text = string.Format("Filling Neriman-${0}", filling.GetPrice() * Convert.ToDouble(NerimanUpdown.Value)); } if (NerimanCombo.SelectedIndex == 0) { NerimanOrder.Text = ""; } }
private void SudeCombo_SelectedIndexChanged(object sender, EventArgs e) { if (SudeCombo.Text == "Tasting 250CC") { SudeOrder.Text = ""; Baverages tasting = new LeShokaladeSude(); tasting = new Tasting(tasting); SudeOrder.Text = string.Format("Tasting Sude-${0}", tasting.GetPrice() * Convert.ToDouble(SudeUpDown.Value)); } if (SudeCombo.Text == "Filling 400CC") { SudeOrder.Text = ""; Baverages filling = new LeShokaladeSude(); filling = new Filling(filling); SudeOrder.Text = string.Format("Filling Sude-${0}", filling.GetPrice() * Convert.ToDouble(SudeUpDown.Value)); } if (SudeCombo.SelectedIndex == 0) { SudeOrder.Text = ""; } }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Tasting = await _context.Tasting.FindAsync(id); if (Tasting != null) { _context.Tasting.Remove(Tasting); var votes = await _context.Vote.Where(x => x.TastingId == id).ToArrayAsync(); _context.Vote.RemoveRange(votes); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
private void GiveOrder_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(Customer.Text)) { MessageBox.Show("Please specify a name!", "Warning!!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { bool control = false; foreach (string choice in ProductList.CheckedItems) { string CustomerSent = Customer.Text; if (choice == "TastingSude") { Baverages tasting = new LeShokaladeSude(); tasting = new Tasting(tasting); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertTakeAway(CustomerSent, choice, tasting.GetPrice()); insert.Execute(); insert.Close(); control = true; } if (choice == "FillingSude") { Baverages filling = new LeShokaladeSude(); filling = new Filling(filling); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertTakeAway(CustomerSent, choice, filling.GetPrice()); insert.Execute(); insert.Close(); control = true; } if (choice == "TastingNeriman") { Baverages tasting = new LeShokaladeNeriman(); tasting = new Tasting(tasting); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertTakeAway(CustomerSent, choice, tasting.GetPrice()); insert.Execute(); insert.Close(); control = true; } if (choice == "FillingNeriman") { Baverages filling = new LeShokaladeNeriman(); filling = new Filling(filling); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertTakeAway(CustomerSent, choice, filling.GetPrice()); insert.Execute(); insert.Close(); control = true; } if (choice == "Lemonade") { Baverages bev = new Lemonade(); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertTakeAway(CustomerSent, bev.GetDescription(), bev.GetPrice()); insert.Execute(); insert.Close(); control = true; } if (choice == "Americano") { Baverages bev = new Americano(); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertTakeAway(CustomerSent, bev.GetDescription(), bev.GetPrice()); insert.Execute(); insert.Close(); control = true; } if (choice == "MilkyAmericano") { Baverages bev = new Americano(); bev = new Milk(bev); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertTakeAway(CustomerSent, bev.GetDescription(), bev.GetPrice()); insert.Execute(); insert.Close(); control = true; } } if (control) { MessageBox.Show("Your order has been received.", "Thank you :)"); AbstractStore store = new LeShokaladeDukkan(); Box.Text = store.OrderDessert("sude").Box(); for (int i = 0; i < ProductList.Items.Count; i++) { ProductList.SetItemChecked(i, false); } Orders.Text = " "; Customer.Text = "Your Name"; } else { MessageBox.Show("You did not choose any order!", "Warning!!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void OrderBtn_Click(object sender, EventArgs e) { bool control = false; if (SudeCombo.Text == "Tasting 250CC") { Baverages tasting = new LeShokaladeSude(); tasting = new Tasting(tasting); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertOrders(Table, "Tasting Sude", tasting.GetPrice() * Convert.ToDouble(SudeUpDown.Value), Convert.ToInt32(SudeUpDown.Value)); insert.Execute(); insert.Close(); control = true; } if (SudeCombo.Text == "Filling 400CC") { Baverages filling = new LeShokaladeSude(); filling = new Filling(filling); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertOrders(Table, "Filling Sude", filling.GetPrice() * Convert.ToDouble(SudeUpDown.Value), Convert.ToInt32(SudeUpDown.Value)); insert.Execute(); insert.Close(); control = true; } if (NerimanCombo.Text == "Tasting 250CC") { Baverages tasting = new LeShokaladeNeriman(); tasting = new Tasting(tasting); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertOrders(Table, "Tasting Neriman", tasting.GetPrice() * Convert.ToDouble(NerimanUpdown.Value), Convert.ToInt32(NerimanUpdown.Value)); insert.Execute(); insert.Close(); control = true; } if (NerimanCombo.Text == "Filling 400CC") { Baverages filling = new LeShokaladeNeriman(); filling = new Filling(filling); DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertOrders(Table, "Filling Neriman", filling.GetPrice() * Convert.ToDouble(NerimanUpdown.Value), Convert.ToInt32(NerimanUpdown.Value)); insert.Execute(); insert.Close(); control = true; } if (WaffleCheck.Checked == true) { DatabaseInsert insert = new DatabaseInsert(); insert.Connection(); insert.InsertOrders(Table, "Waffle", 10 * Convert.ToInt32(WaffleUpDown.Value), Convert.ToInt32(WaffleUpDown.Value)); insert.Execute(); insert.Close(); control = true; } if (control) { MessageBox.Show("Your order has been received.", "Thank You :)"); SudeCombo.SelectedIndex = 0; NerimanCombo.SelectedIndex = 0; WaffleCheck.Checked = false; } else { MessageBox.Show("You did not choose any order!", "Warning!!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }