예제 #1
0
        public async Task <IActionResult> Delete(OrderItem item)
        {
            try
            {
                var itemAux = await _repo.GetOrderItemAsync(item.OrderId, item.ProductId);

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

                _repo.Delete(itemAux);

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

            return(BadRequest());
        }
예제 #2
0
        public void TestDelete()
        {
            var orderitems      = oir.GetOrderItems();
            int orderitemscount = orderitems.Count();

            oir.Delete(orderitems[orderitemscount - 1].Id);
            var lastorderitem = oir.GetOrderItems().Last();

            Assert.AreEqual(lastorderitem.Id, OI.Id, "Id should be equal");
        }
예제 #3
0
        public ActionResult DeleteItem(int id)
        {
            JsonResult          result        = new JsonResult();
            OrderItemRepository orderItemRepo = new OrderItemRepository(applicationCache);
            var             model             = orderItemRepo.Get(id);
            OrderRepository orderRepo         = new OrderRepository(false, loggedInUser.Id, applicationCache);

            result.Data = orderItemRepo.Delete(model);
            return(result);
        }
예제 #4
0
 public void Delete(OrderItem order_item)
 {
     _repository.Delete(order_item);
 }