Exemplo n.º 1
0
        public override void ReverseInit(object returnedData)
        {
            base.ReverseInit(returnedData);

            if (returnedData is ProductQuotationModel)
            {
                DeleteItemCommand.Execute(returnedData);
            }
        }
Exemplo n.º 2
0
        private void clearItems(UpdateOrderViewModel model, Order order)
        {
            var itemCmd = new DeleteItemCommand(_itemRepository, _itemValidator);

            foreach (var item in order.Items)
            {
                if (!model.Items.Any(i => i.Description == item.Description))
                {
                    itemCmd.Execute(item);
                    AddNotifications(itemCmd);
                }
            }
        }
Exemplo n.º 3
0
        public void Execute_DeleteItemCommand_WithPosition_ShouldRemoveItemFromItemsList()
        {
            var documentItems = new List <DocumentItem>
            {
                new DocumentItem(new TestParagraph()),
                new DocumentItem(new TestParagraph())
            };
            var command = new DeleteItemCommand(documentItems, 1);

            command.Execute();

            Assert.AreEqual(1, documentItems.Count);
        }
Exemplo n.º 4
0
        public override void OnReceive(Context context, Intent intent)
        {
            if (intent != null)
            {
                var itemId = intent.GetStringExtra("itemId");

                var deleteCommand = new DeleteItemCommand(PCLStorage.FileSystem.Current.LocalStorage);
                deleteCommand.Execute(itemId);

                var manager = NotificationManager.FromContext(context);
                manager.CancelAll();
            }
        }
Exemplo n.º 5
0
        public void CanCreateCommandAndDeleteItemOnExecute()
        {
            var items = new List <DocumentItem>
            {
                new DocumentItem(new TestParagraph()),
            };

            Assert.AreEqual(items.Count, 1);
            DeleteItemCommand c = new DeleteItemCommand(0, items);

            c.Execute();
            Assert.AreEqual(items.Count, 0);
        }
Exemplo n.º 6
0
        public void Execute_DeleteItemInvoked()
        {
            // Arrange
            bool isDeleteItemInvoked = false;

            _documentMock.Setup(d => d.DeleteItem(It.IsAny <int>())).Callback(() => isDeleteItemInvoked = true);
            ICommand command = new DeleteItemCommand(1, _documentMock.Object);

            // Act
            command.Execute();

            // Assert
            Assert.True(isDeleteItemInvoked);
        }
Exemplo n.º 7
0
 private void DeleteItem(object parameter)
 {
     if (DeleteItemCommand != null)
     {
         DeleteItemCommand.Execute(parameter);
     }
     else
     {
         (ItemsSource as IList).Remove(CurrentItem);
     }
     if (CurrentItemIndex != 1 && ItemsCount > 1 || CurrentItemIndex == 1 && ItemsCount == 1)
     {
         _currentItemIndex--;
     }
     UpdateItemsCount();
     UnsafelyAlterItemIndex(_currentItemIndex);
 }
Exemplo n.º 8
0
        public void DeleteItemCommandExecutor(string commandParams)
        {
            var argumentsParser = new ArgumentsParser(commandParams);

            if (argumentsParser.NextArgumentsCount != 1)
            {
                throw new MenuException();
            }

            int?position = argumentsParser.GetNextAsInt();

            if (position == null)
            {
                throw new MenuException();
            }

            ICommand command = new DeleteItemCommand(position.Value, _document);

            command.Execute();
        }
Exemplo n.º 9
0
        public void Unexecute_InsertItemInvoked()
        {
            // Arrange
            var imageDocumentItem = new DocumentItem(new ImageClass("", "", 1, 1));

            bool isInsertItemInvoked = false;

            _documentMock
            .Setup(d => d.InsertImage(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>()))
            .Callback(() => isInsertItemInvoked = true);
            _documentMock.Setup(d => d.GetItem(It.IsAny <int>())).Returns(imageDocumentItem);
            ICommand command = new DeleteItemCommand(1, _documentMock.Object);

            command.Execute();

            // Act
            command.Unexecute();

            // Assert
            Assert.True(isInsertItemInvoked);
        }
Exemplo n.º 10
0
        public void Delete(string id)
        {
            var order = _orderRepository.GetById(id).Result;

            if (order == null)
            {
                AddNotification("Pedido", "Nenhum pedido com este código pode ser encontrado!");
                return;
            }
            if (order.ApprovedItens > 0 || order.ApprovedValue > 0)
            {
                AddNotification("Pedido", "Exclusão cancelada! O pedido já foi aprovado.");
                return;
            }

            if (Valid)
            {
                var itemCmd = new DeleteItemCommand(_itemRepository, _itemValidator);
                foreach (var item in order.Items)
                {
                    itemCmd.Execute(item);
                    AddNotifications(itemCmd);
                }
            }

            if (Valid)
            {
                var orderCmd = new DeleteOrderCommand(_orderRepository);
                orderCmd.Execute(order);
                AddNotifications(orderCmd);
            }

            if (Valid)
            {
                _context.SaveChanges();
            }
        }