public async Task <IHttpActionResult> Post(OrderLine item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } item.ObjectState = ObjectState.Added; _service.Insert(item); try { await _unitOfWorkAsync.SaveChangesAsync(); } catch (DbUpdateException) { if (ItemExists(item.OrderLineID)) { return(Conflict()); } throw; } return(Created(item)); }