public ActionResult DeleteConfirmed(int idItem) { try { ISoldProductModel product = soldProductData.FindById(idItem); ITableModel table = tableData.GetAll().Where(x => x.ID == product.TableID).FirstOrDefault(); //if the table is without any product set it to empty if (table.SoldProducts.Count() == 1) { table.Occupied = false; tableData.Update(table); } soldProductData.Delete(idItem); return(RedirectToAction("TableCategories", new { id = product.TableID })); } catch (Exception ex) { log.Error("Could't load sold products or tables from Database", ex); return(View("ErrorRetriveData")); } }
// DELETE: api/SoldProducts/5 public void Delete(int id) { soldProductData.Delete(id); }