public async Task <IHttpActionResult> Put([FromODataUri] int StockItemID, StockItem item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (StockItemID == item.StockItemID) { return(BadRequest()); } item.ObjectState = ObjectState.Modified; _service.Update(item); try { await _unitOfWorkAsync.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemExists(StockItemID)) { return(NotFound()); } throw; } return(Updated(item)); }
public IActionResult Update(int id, [FromBody] StockItemDto stockItemDto) { var stockItem = mapper.Map <StockItem>(stockItemDto); stockItem.StockItemId = id; try { stockItemService.Update(stockItem); return(Ok()); } catch (ApplicationException ex) { return(BadRequest(new { messaage = ex.Message })); } }