public async Task <IHttpActionResult> Post(OrderModel o) { try { if (ModelState.IsValid) { var order = _mapper.Map <Order>(o); _repo.AddOrder(order); if (await _repo.SaveChangesAsync()) { var newOrderModel = _mapper.Map <OrderModel>(order); return(Created("GetOrder", new { orderId = newOrderModel.OrderId })); } } } catch (Exception ex) { return(BadRequest(ex.Message)); } return(BadRequest()); }