public ActionResult SubInv_Update([DataSourceRequest] DataSourceRequest request, SubInvModel model) { if (model != null && ModelState.IsValid) { //productService.Update(model); SubInventory subinv = Mappings.ToEntity(model); subinv.ObjectState = ObjectState.Modified; subinv.ModifiedBy = "I-ALI"; subinv.ModifiedDate = DateTime.Now; _subInventoryService.Update(subinv); try { _unitOfWorkAsync.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ItemExists(model.SubInvCode)) { throw new Exception("Item does not exist."); } throw; } } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }
// PUT: odata/subinventory(5) public async Task <IHttpActionResult> Put(string key, SubInventory subinventory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (key != subinventory.SubInvCode) { return(BadRequest()); } subinventory.ObjectState = ObjectState.Modified; _subInventoryService.Update(subinventory); try { await _unitOfWorkAsync.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemExists(key)) { return(NotFound()); } throw; } return(Updated(subinventory)); }