public async Task<IHttpActionResult> PutOrderDelivered(int id, OrderDelivered orderDelivered) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != orderDelivered.Id) { return BadRequest(); } db.Entry(orderDelivered).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderDeliveredExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostOrderDelivered(OrderDeliveredBinding orderDeliveredModel) { if (!ModelState.IsValid) { return BadRequest(ModelState); } ApplicationUser appuser = await _userManager.FindByIdAsync(User.Identity.GetUserId()); var orderDelivered = new OrderDelivered() { OrderStatus = await db.OrderStatus.FindAsync(orderDeliveredModel.OrderStatusId), Order = await db.Orders.FindAsync(orderDeliveredModel.OrderId), Comment = orderDeliveredModel.Comment, User = appuser }; db.OrderDelivereds.Add(orderDelivered); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = orderDelivered.Id }, orderDelivered); }