public override void Execute()
        {
            OrderItem orderItem;

            TypedResult = new DeleteOrderItemResult();
            UserName    = AuditInfo.InvokedBy;

            if (!String.IsNullOrWhiteSpace(SupplierName))
            {
                orderItem = GetLastOrderItemBySupplierName(SupplierName);
            }
            else
            {
                orderItem = GetLastOrderItem(UserName);
            }

            if (orderItem == null)
            {
                throw new AppException(ErrorCodes.OrderItem.NoOrderItemToDelete);
            }

            TypedResult.OrderContent = orderItem.Content;
            TypedResult.Order        = orderItem.Order;
            TypedResult.User         = orderItem.User;

            orderItemRepository.Delete(orderItem);

            base.Execute();
        }
Example #2
0
        public async Task <Response> Delete(int id)
        {
            try
            {
                var item = await _repository.GetById(id);

                if (item == null)
                {
                    return(NotFoundResponse("Item não encontrado."));
                }

                _repository.Delete(item);

                if (await _repository.SaveChangesAsync())
                {
                    return(OkResponse("Item deletado."));
                }

                return(BadRequestResponse("Erro desconhecido."));
            }
            catch (Exception ex)
            {
                return(BadRequestResponse(ex.Message));
            }
        }
        public void DeleteOrderItem(int orderItemId)
        {
            //Get orderItem by id.
            var orderItem = orderItemRepository.GetById(orderItemId);

            if (orderItem != null)
            {
                orderItemRepository.Delete(orderItem);
                SaveOrderItem();
            }
        }
Example #4
0
        public void Delete(Guid id)
        {
            _unitOfWork.BeginTransaction();
            var orderItem = _orderItemRepository.GetById(id);

            if (orderItem == null)
            {
                _unitOfWork.Commit();
                throw new Exception(ExceptionMessages.OrderItemException.NOT_FOUND);
            }
            _orderItemRepository.Delete(orderItem);
            _unitOfWork.Commit();
        }
Example #5
0
        public bool RemoveOrderItem(int orderItemId, string userId)
        {
            var item = _orderItemRepo.FindById(orderItemId);

            if (_orderRepo.FindById(item?.OrderId)?.State == (int)OrderStatus.New &&
                _orderItemRepo.Delete(orderItemId, userId))
            {
                return(true);
            }
            else
            {
                throw new Exception($"Failed to remove orderItem: {orderItemId}");
            }
        }
        public bool DeleteOrderItem(OrderItem order_item)
        {
            if (order_item == null)
            {
                throw new ArgumentNullException(nameof(order_item));
            }

            return(ExecuteFaultHandledOperation(() =>
            {
                var ord_itm = _order_item_se.Map(order_item);
                ord_itm.OrderItemKey = order_item.OrderItemKey;
                _order_item_repo.Delete(ord_itm);
                return true;
            }));
        }
Example #7
0
        public IActionResult Remove(int id)
        {
            var sessionData = HttpContext.Session.GetString(Session.Key);

            if (string.IsNullOrEmpty(sessionData))
            {
                _logger.LogError("Attempt to remove order item before accessing products list");
                return(StatusCode(500));
            }

            var session = JsonConvert.DeserializeObject <Session>(sessionData);

            var orderToDelete = _orderItemRepository.GetById(id);

            _orderItemRepository.Delete(orderToDelete);
            _orderItemRepository.Save();

            _logger.LogInformation($"Removed order item {id} for user's {session.ID} cart");

            return(RedirectToAction("Index"));
        }
Example #8
0
 public void Delete(OrderItemEntity entity)
 {
     service.Delete(entity);
 }
Example #9
0
 public void Delete(string id)
 => _orderItemRepository.Delete(id);
Example #10
0
 public void Delete(int id)
 {
     orderItemRepository.Delete(id);
 }
Example #11
0
 public void Delete(int id)
 {
     _repository.Delete(id);
 }
Example #12
0
 public void DeleteOrderItem(int Id)
 {
     _orderItemRepository.Delete(Id);
 }
 public bool Delete(Guid id)
 {
     return(_orderItemRepository.Delete(id));
 }
Example #14
0
 public void Delete(OrderItem OrderItem)
 {
     OrderItemRepository.Delete(OrderItem);
 }