public async Task <ActionResult> DeleteConfirmed(int id) { using (DAL.BarContext db = new DAL.BarContext()) { Order order = await db.Orders.FindAsync(id); db.Orders.Remove(order); await db.SaveChangesAsync(); return(RedirectToAction("YourOrder")); } }
public async Task <ActionResult> Delete(int?id) { using (DAL.BarContext db = new DAL.BarContext()) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Order order = await db.Orders.FindAsync(id); if (order == null) { return(HttpNotFound()); } return(View(order)); } }