public async Task <IActionResult> Delete(int id) { var oldBill = await _ctx.TimeBills .Where(b => b.Id == id) .FirstOrDefaultAsync(); if (oldBill == null) { return(NotFound()); } _ctx.Remove(oldBill); if (await _ctx.SaveChangesAsync() > 0) { return(Ok()); } return(BadRequest("Failed to save new timebill")); }
public async Task <ActionResult> FinalisePost([FromBody] Models.Payment Payment) { //INSERT TRANSACTION LOGIC HERE (THIS APP DOESN'T TAKE MONEY FROM REAL ACCOUNTS) if (Payment == null) { return(new StatusCodeResult(400)); } try { await PostInvoice(); await NotifyOrdering(); foreach (BillingProduct bp in Payment.Order.Products) { db.Products.Remove(bp); } db.Remove(Payment.Order); db.SaveChanges(); } catch { return(new StatusCodeResult(500)); } return(Redirect("http://localhost:54330/Products/Index")); }