public async Task <ServiceResponeCode> CreateAsync(OrderDetail entityToCreate)
        {
            if (entityToCreate.Id != 0)
            {
                return(ServiceResponeCode.INVALID);
            }
            try
            {
                await _orderDetailRepository.CreateAsync(entityToCreate);

                return(ServiceResponeCode.OK);
            }
            catch
            {
                return(ServiceResponeCode.ERROR);
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <OrderDetail> > Post([FromBody] OrderDetail orderDetail)
        {
            try
            {
                orderDetail.OrderDetailID = Guid.NewGuid();
                await orderDetailRepo.CreateAsync(orderDetail);

                return(CreatedAtRoute("GetOrderDetailByID",
                                      new
                {
                    id = orderDetail.OrderDetailID
                },
                                      orderDetail));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }