public ProjectItemViewModel(T model) { Model = model; RemoveItemCommand = ReactiveCommand.Create(); RemoveItemCommand.Subscribe(o => { }); OpenInExplorerCommand = ReactiveCommand.Create(); OpenInExplorerCommand.Subscribe(o => { if (model is IProjectFolder) { Platform.OpenFolderInExplorer((model as IProjectFolder).Location); } else if (model is IProjectItem) { Platform.OpenFolderInExplorer((model as IProjectItem).Parent.Location); } }); textBoxVisibility = false; labelVisibility = true; }
public ucCraftingTree() { SortingTypes = new ObservableCollection <string> { "----------", "Name", "Category", "Required (High to Low)", "Required (Low to High)" }; SortType = "----------"; Categories = new ObservableCollection <string> { "All", "Building Blocks", "Decorations", "Redstone", "Transportation", "Miscellaneous", "Foodstuffs", "Brewing", "Combat" }; CategoryIndex = 0; AddItemCommand = new AddItemCommand(this); RemoveItemCommand = new RemoveItemCommand(this); InitializeComponent(); LayoutRoot.DataContext = this; }
private void Handle(RemoveItemCommand command) { var actor = GetCart(command.CartId); actor.Tell(command); pendingOperations.Add(command.Id, Sender); }
public ItemsViewModel() { CreateItemCommand = new CreateItemCommand(this); RemoveItemCommand = new RemoveItemCommand(this); ItemsList = System.Threading.Tasks.Task.Run(() => GetItems()).Result; NewItemName = ""; }
public WithdrawalsPageViewModel(AccountModel accountModel, Mediator mediator) { GoToNextPage = new RelayCommand <object>(arg => mediator.Invoke("OnGoToNextPage")); GoToPreviousPage = new RelayCommand <object>(arg => mediator.Invoke("OnGoToPreviousPage")); OnRemoveWithdrawal = new RemoveItemCommand(accountModel.RemoveWithdrawal); OnAddWithdrawal = new AddItemCommand(accountModel.AddWithdrawal); AccountModel = accountModel; }
public async Task <IActionResult> RemoveItem(int uId, int gId, int sId, int itId) { var removeItemCommand = new RemoveItemCommand(itId, uId, gId, sId); await _mediator.Send(removeItemCommand); return(Ok()); }
public AdditionalDepositsPageViewModel(AccountModel accountModel, Mediator mediator) { GoToNextPage = new RelayCommand <object>(arg => mediator.Invoke("OnGoToNextPage")); GoToPreviousPage = new RelayCommand <object>(arg => mediator.Invoke("OnGoToPreviousPage")); OnRemoveDeposit = new RemoveItemCommand(accountModel.RemoveDeposit); OnAddDeposit = new AddItemCommand(accountModel.AddDeposit); AccountModel = accountModel; }
public void TestExecuteParameterIsNotListBoxItem() { List <decimal> itemList = new List <decimal>(); RemoveItemCommand removeItemCommand = new RemoveItemCommand(itemList.RemoveAt); var exception = Assert.ThrowsException <ArgumentException>(() => { removeItemCommand.Execute(new TextBox()); }); Assert.AreEqual("parameter is not a ListBoxItem", exception.Message); }
public async Task <IActionResult> RemoveItem(string id, [FromBody] RemoveItemCommand command, CancellationToken cancellationToken) { var basketAggregate = await _repository.Load(id, cancellationToken); basketAggregate.Apply(command); await _repository.Save(basketAggregate, cancellationToken); return(Ok()); }
/// <inheritdoc /> public void Clear() { ViewModels.Clear(); EncapsulatedList.Clear(); OnAllPropertiesChanged(); CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); ClearItemCsommand.OnCanExecuteChanged(); RemoveItemCommand.OnCanExecuteChanged(); }
public void Apply(RemoveItemCommand command) { var product = Items.SingleOrDefault(item => item.Sku == command.Sku); if (product == null) { return; } Items.Remove(product); HasBeenUpdated = true; }
public void Insert(int index, TViewModel item) { if (ViewModels.Contains(item) || EncapsulatedList.Contains(item?.Model)) { throw new NotSupportedException("The item was already added to the collection"); } ViewModels.Insert(index, item); EncapsulatedList.Insert(index, item?.Model); CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index)); ClearItemCsommand.OnCanExecuteChanged(); RemoveItemCommand.OnCanExecuteChanged(); OnAllPropertiesChanged(); }
public async Task <IActionResult> RemoveItemInOrderItemList([FromBody] RemoveItemCommand command) { if (command == null) { return(await Respond(null, new List <Notification> { new Notification("Order", "Parameters is invalid.") })); } var result = _orderCommandHandler.Handle(command); return(await Respond(result, _orderCommandHandler.Notifications)); }
/// <inheritdoc /> public bool Remove(TViewModel item) { int index = ViewModels.IndexOf(item); bool returnValue = ViewModels.Remove(item); EncapsulatedList.Remove(item?.Model); CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, index)); ClearItemCsommand.OnCanExecuteChanged(); RemoveItemCommand.OnCanExecuteChanged(); OnAllPropertiesChanged(); return(returnValue); }
/// <inheritdoc /> public void Add(TViewModel item) { if (ViewModels.Contains(item) || EncapsulatedList.Any(i => ReferenceEquals(i, item?.Model))) { throw new NotSupportedException("The item was already added to the collection"); } ViewModels.Add(item); EncapsulatedList.Add(item?.Model); CollectionChanged?.Invoke(ViewModels, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item)); OnAllPropertiesChanged(); ClearItemCsommand.OnCanExecuteChanged(); RemoveItemCommand.OnCanExecuteChanged(); }
private void LoadItems() { //this.currentPage.TxtB1.Text = "Bonjour"; using (var db = new GriffonWpfContext()) { foreach (var item in db.Users.ToList()) { users.Add(item); } } this.currentPage.listViewUsers.ItemsSource = users; this.RemoveItem = new RemoveItemCommand(); }
private void Handle(RemoveItemCommand command) { if (!isInitialized) { Sender.Tell(new CommandFailed(command.Id, "Cart is not initialized!")); return; } if (!items.ContainsKey(command.ItemId) || items[command.ItemId] < command.Quantity) { Sender.Tell(new CommandFailed(command.Id, "Not enough quantity!")); return; } items[command.ItemId] -= command.Quantity; Sender.Tell(new ItemRemovedEvent(command.Id, command.CartId, command.ItemId, command.Quantity)); }
public MainWindowViewModel() { this.WhenAnyValue(x => x.ItemCount).Subscribe(ResizeItems); RecreateCommand = ReactiveCommand.Create(); RecreateCommand.Subscribe(_ => Recreate()); AddItemCommand = ReactiveCommand.Create(); AddItemCommand.Subscribe(_ => AddItem()); RemoveItemCommand = ReactiveCommand.Create(); RemoveItemCommand.Subscribe(_ => Remove()); SelectFirstCommand = ReactiveCommand.Create(); SelectFirstCommand.Subscribe(_ => SelectItem(0)); SelectLastCommand = ReactiveCommand.Create(); SelectLastCommand.Subscribe(_ => SelectItem(Items.Count - 1)); }
public void TestExecute() { List <decimal> itemList = new List <decimal>() { 15.00M, 50.00M, 20.00M }; RemoveItemCommand removeItemCommand = new RemoveItemCommand(itemList.RemoveAt); ListBoxItem listBoxItem = new ListBoxItem() { Content = new Tuple <decimal, int>(50.00M, 1) }; removeItemCommand.Execute(listBoxItem); Assert.AreEqual(2, itemList.Count); Assert.AreEqual(15.00M, itemList[0]); Assert.AreEqual(20.00M, itemList[1]); }
public ICommandResult Handle(RemoveItemCommand command) { var order = _orderAdoRepository.GetLastCreatedOrderById(command.OrderId); if (order == null) { AddNotification("Order", "Order isn't found."); return(null); } order.RemoveItem(command.OrderItemId); AddNotifications(order.Notifications); if (Invalid) { return(null); } _orderItemAdoRepository.Delete(command.OrderItemId); return(new ReturnedItemCommandResult(order.Id, command.ProductName)); }
public Task <string> RemoveItemAsync(RemoveItemCommand cmd) => base.RequestAsync(cmd);
public void handleRemoveItemCommand(RemoveItemCommand removeItemCommand) { int sourceId=-1; int sourceClassId=-1; String sourceClassName=null; try { sourceId=removeItemCommand.getSourceId(); sourceClassId=removeItemCommand.getSourceClassId(); sourceClassName=modelManager.getStringFromInteger(sourceClassId); Persisted persisted = registry.remove(sourceClassId,sourceId); persisted.setPlanckDBPhantom(true); } catch (Exception e) { removeItemCommand.setCommandSatus(CommandStatus.failOnRemovingItem); log.Error(CommandStatus.failOnRemovingItem.getMessage() + "item class = "+sourceClassName+" item id = "+ sourceId ,e); } }
public async Task <ValidationResult> RemoveItemAsync(Guid id) { var removeItemCommand = new RemoveItemCommand(id); return(await _meditor.SendCommand(removeItemCommand)); }
public void RemoveItem(RemoveItemCommand cmd) { ShoppingCartItem existingItem = items.Where(item => item.CreateSnapshot().ItemId == cmd.ItemId).FirstOrDefault(); if (existingItem != null) items.Remove(existingItem); Sum(); }
public IActionResult RemoveItem([FromRoute] RemoveItemCommand command) { var result = cartService.Delete(command); return(Ok(new { command.SessionId, command.ProductId })); }