예제 #1
0
        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());
        }