public ShoppingItemDetailViewModel(ShoppingItemModel source, IShoppingCartService shoppingCartService, INavigationService navigationService) : base(source, navigationService) { ShoppingCartService = shoppingCartService; AddToCartCommand = new ReactiveCommand(); _addToCartSubscription = AddToCartCommand.Subscribe(AddToCart); }
public async Task <ShoppingItemModel> CreateTemplateItem(IdModel templateId, ShoppingItemModel item, CancellationToken cancellationToken) { var newItemId = await repository.CreateItem(templateId, item, cancellationToken); item.Id = newItemId; return(item); }
private void AdjustItemCount(ShoppingItemModel item, int quantity) { var count = 0; _cart.TryGetValue(item, out count); count += quantity; SetItemCount(item, count); }
public ObservableCollection <ShoppingItemModel> RemoveItem(ShoppingItemModel item) { //wrap try catch - exception when working OnPropertyChanged("Remove"); _currentList.Remove(item); CurrentList = _currentList; return(CurrentList); }
public ObservableCollection <ShoppingItemModel> AddItem(ShoppingItemModel item) { //wrap try catch - exception when working _currentList.Add(item); CurrentList = _currentList; return(CurrentList); }
public ShoppingCartItemViewModel(ShoppingItemModel source, int count, IShoppingCartService shoppingCartService, INavigationService navigationService) : base(source, navigationService) { _shoppingCartService = shoppingCartService; Count = new ReactiveProperty <int>(count); CountAndPriceLabel = Count.CombineLatest(PriceLabel, (cnt, pce) => $"{cnt}x @ {pce} ea.").ToReadOnlyReactiveProperty(); RemoveCommand = new ReactiveCommand(); _removeSubscription = RemoveCommand.Subscribe(RemoveItem); }
public ShoppingItemDetailPage(ShoppingItemModel item) { Title = item.Name; var navigationService = IoC.Container.Resolve <INavigationService>(); var shoppingCartService = IoC.Container.Resolve <IShoppingCartService>(); BindingContext = new ShoppingItemDetailViewModel(item, shoppingCartService, navigationService); Content = new ShoppingItemDetailView(); }
public ShoppingItemDocument(ShoppingItemModel item) { if (item.Id != null) { Id = item.Id.ToObjectId(); } Title = item.Title; Quantity = item.Quantity; Comment = item.Comment; }
public ShoppingCartServiceTest() { _shoppingCartService = new ShoppingCartService(); _shoppingItemA = new ShoppingItemModel { Id = Guid.NewGuid(), Name = "Item A", Description = "Description A", Price = 5.0 }; _shoppingItemB = new ShoppingItemModel { Id = Guid.NewGuid(), Name = "Item B", Description = "Description B", Price = 250.0 }; }
public async Task <IdModel> CreateItem(IdModel shoppingListId, ShoppingItemModel item, CancellationToken cancellationToken) { var newItem = new ShoppingItemDocument(item) { Id = ObjectId.GenerateNewId(), }; await itemsRepository.CreateItem(shoppingListId.ToObjectId(), newItem, cancellationToken); return(newItem.Id.ToIdModel()); }
private void SetItemCount(ShoppingItemModel item, int quantity) { if (quantity > 0) { _cart[item] = quantity; } else { _cart.Remove(item); } TriggerUpdate(); }
public ShoppingItemViewModel(ShoppingItemModel source, INavigationService navigationService) { NavigationService = navigationService; Name = new ReactiveProperty <string>(source.Name); Icon = new ReactiveProperty <string>(source.Icon); Description = new ReactiveProperty <string>(source.Description); PriceLabel = new ReactiveProperty <string>($"{source.Price:C}"); Item = source; ViewDetailsCommand = new ReactiveCommand(); _viewSubscription = ViewDetailsCommand.Subscribe(ViewDetails); }
private void SaveAnItem() { //store the entered item details. ItemId = Guid.NewGuid(); ItemEditMode = false; ItemName = ItemName; ItemQty = ItemQty; ItemPrice = ItemPrice; newItem = new ShoppingItemModel(ItemId, ItemEditMode, ItemName, ItemQty, ItemPrice); // Call the delegate AddItem method currList.AddItem(newItem); //Close the dialogue box/window & may be give user output message. CloseDialogTrue(); }
public void RemoveItem(ShoppingItemModel item, int quantity = Int32.MaxValue) { AdjustItemCount(item, quantity * -1); }
public void AddItem(ShoppingItemModel item, int quantity = 1) { AdjustItemCount(item, quantity); }
public Task UpdateItem(IdModel shoppingListId, ShoppingItemModel item, CancellationToken cancellationToken) { return(itemsRepository.UpdateItem(shoppingListId.ToObjectId(), new ShoppingItemDocument(item), cancellationToken)); }
public Task UpdateShoppingListItem(IdModel shoppingListId, ShoppingItemModel item, CancellationToken cancellationToken) { return(repository.UpdateItem(shoppingListId, item, cancellationToken)); }
public OutputShoppingItemData(ShoppingItemModel item) : base(item) { Id = item.Id.Value; }
public ShoppingListViewModel() { _currentList = new ObservableCollection <ShoppingItemModel>(); _currentItem = new ShoppingItemModel(); }
protected BasicShoppingItemData(ShoppingItemModel item) { Title = item.Title; Quantity = item.Quantity; Comment = item.Comment; }
public Task UpdateTemplateItem(IdModel templateId, ShoppingItemModel item, CancellationToken cancellationToken) { return(repository.UpdateItem(templateId, item, cancellationToken)); }