Пример #1
0
        public async Task <IActionResult> Update(OrderItem item)
        {
            try
            {
                var itemAux = (OrderItem)await _repo.GetOrderItemAsync(item.OrderId, item.ProductId);

                if (itemAux == null)
                {
                    return(NotFound());
                }

                itemAux.Price    = item.Price;
                itemAux.Quantity = item.Quantity;

                _repo.Update(itemAux);

                if (await _repo.SaveChangesAsync())
                {
                    return(Ok(itemAux));
                }
            }
            catch (System.Exception ex)
            {
                return(this.StatusCode(
                           StatusCodes.Status500InternalServerError,
                           "Erro ao atualizar o item do pedido\n"
                           + ex.InnerException));
            }

            return(BadRequest());
        }
Пример #2
0
        public void TestUpdate()
        {
            var orderitems      = oir.GetOrderItems();
            int orderitemscount = orderitems.Count();

            OI.ProductId = 3;
            oir.Update(OI);
            Assert.AreEqual(OI.ProductId, 3, "ProductId should be 3");
        }
Пример #3
0
 public void Update(OrderItem order_item)
 {
     _repository.Update(order_item);
 }