public override void ReverseInit(object returnedData) { base.ReverseInit(returnedData); if (returnedData is ProductQuotationModel) { DeleteItemCommand.Execute(returnedData); } }
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); } } }
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); }
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(); } }
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); }
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); }
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); }
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(); }
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); }
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(); } }