public async Task <IHttpActionResult> PostOrder(Containers.Models.EasyInputs.EasyOrder order) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DB.Order outputOrder = new DB.Order(); outputOrder = order.ToDBOrder(); db.Order.Add(order.ToDBOrder()); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = outputOrder.Id }, outputOrder)); }
public async Task <IHttpActionResult> PutOrder(int id, Containers.Models.EasyInputs.EasyOrder order) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DB.Order orderDb = order.ToDBOrder(); orderDb.Id = id; db.Entry(orderDb).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }