public async Task <ActionResult <Order> > PostOrder(Order order) { try { var errors = OrderValidator.GetValidationErrors(order); if (errors.Count > 0) { return(BadRequest(errors)); } } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, new { Error = ex.Message })); } _context.Orders.Add(order); await _context.SaveChangesAsync(); return(CreatedAtAction("GetOrder", new { id = order.Id }, order)); }