public async Task <IHttpActionResult> Post(int orderId, OrderDetailModel[] ods) { try { if (ModelState.IsValid) { var orderDetail = _mapper.Map <OrderDetail[]>(ods); _repo.AddOrderDetail(orderDetail, orderId); if (await _repo.SaveChangesAsync()) { return(Created("GetOrder", new { orderId = orderId })); } } } catch (Exception ex) { return(BadRequest(ex.Message)); } return(BadRequest()); }