// DELETE: odata/subinventory(5) public async Task <IHttpActionResult> Delete(string key) { SubInventory subinventory = await _subInventoryService.FindAsync(key); if (subinventory == null) { return(NotFound()); } subinventory.ObjectState = ObjectState.Deleted; _subInventoryService.Delete(subinventory); await _unitOfWorkAsync.SaveChangesAsync(); return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult SubInv_Destroy([DataSourceRequest] DataSourceRequest request, SubInvModel model) { if (model != null) { //productService.Destroy(model); SubInventory subinv = _subInventoryService.Find(model.SubInvCode); if (subinv == null) { throw new Exception("Item does not exist."); } subinv.ObjectState = ObjectState.Deleted; _subInventoryService.Delete(subinv); _unitOfWorkAsync.SaveChanges(); } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }