public async Task <IActionResult> Edit(int id, [Bind("orderNumber,Bake,Flavor,Size,Filling,FillFlavor,Comment,customerName,Date,DueDate")] CustomOrderModel orderModel) { if (id != orderModel.CustomBakeID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(orderModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderModelExists(orderModel.CustomBakeID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(orderModel)); }
public async Task <IActionResult> Create([Bind("orderNumber,Bake,Flavor,Size,Filling,FillFlavor,Comment,customerName,Date,DueDate")] CustomOrderModel orderModel) { if (ModelState.IsValid) { _context.Add(orderModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(orderModel)); }
public IActionResult Details(CustomOrderModel data) { ViewData["Bake"] = data.Bake; data.ConfirmationNumber = Guid.NewGuid().ToString(); data.Date = DateTime.Now; ViewData["ID"] = data.ConfirmationNumber; using (var context = new FerrisBakesContext()) { context.CustomOrders.Add(data); //Context.Order.ToList context.SaveChanges(); } return(View("OrderPlaced", data)); }
public IActionResult Form(CustomOrderModel data) { ViewData["Bake"] = data.Bake; ViewData["Sizing"] = data.Bake switch { "Bars" => "Size is number of pans.", "Brownies" => "Size is number of pans.", "Cake" => "Size is number of cakes", "Cupcake" => "Size is dozens of cupcakes.", "Cookies" => "Size is in dozens.", "Pastry" => "Size is in individual items.", "Pie" => "Size is in individual items.", _ => "Size is in individual items.", }; data.CalculatePrice(); return(View("Details", data)); //return View(data); }