public virtual void AddProduct(Product product) { var productCategory = new ProductCategory { Category = this, Product = product }; product.ProductCategories.Add(productCategory); ProductCategories.Add(productCategory); }
public virtual void AddCategory(Category category) { var productCategory = new ProductCategory { Category = category, Product = this }; ProductCategories.Add(productCategory); category.ProductCategories.Add(productCategory); }
public virtual void AddCategory(Category category, int position) { var productCategory = new ProductCategory { Category = category, Product = this, Position = position }; ProductCategories.Add(productCategory); category.ProductCategories.Add(productCategory); }
private void OnAfterCategorySaved(Category model) { var category = ProductCategories.SingleOrDefault(x => x.Id == model.Id); if (category == null) { ProductCategories.Add(new CategoryWrapper(model)); } else { category.Update(model); } }
public void AddCategory(Guid categoryId) { try { var productCategory = new ProductCategory() { ProductId = Id, CategoryId = categoryId }; ProductCategories.Add(productCategory); } catch (Exception e) { throw new Exception(e.Message); } }
// Constructor public EditTransactionViewModel(TransactionHeadListEntity item, bool newRecord, string itemName) : base(item, newRecord, itemName) { TransactionDate = Item.Head.Date; this.TransactionBody.CollectionChanged += this.OnCollectionChanged; if (Item.Head.Id > 0) { var list = ManageTransactions.ListBody(Item.Head.Id); foreach (var record in list) { TransactionBody.Add(new BindableTransactionBodyListEntity(record)); } } if (Item.Head.Incoming) { Partners = ManagePartners.ListDealers(); } else { Partners = ManagePartners.ListCustomers(); } if (Item.Partner != null) { foreach (var record in Partners.Where(p => p.Id == Item.Partner.Id)) { SelectedPartner = record; } } SelectedProductCategory = new ProductCategoryEntity() { Category = " - All product categories - ", Id = 0 }; ProductCategories.Add(SelectedProductCategory); ProductCategories.AddRange(ManageProducts.ListProductCategories()); }
private void PreInit() { var first = new ListViewItem(); first.Tag = -1; first.Content = "..."; ProductCategories.Add(first); foreach (var el in manager.Repository.ProductCategories) { var tmp = new ListViewItem(); tmp.Tag = el.ProductCategoryID; tmp.Content = el.Name; ProductCategories.Add(tmp); } foreach (var el in manager.Repository.Products) { var tmp = new ListViewItem(); tmp.Tag = el.ProductID; tmp.Content = el.Name; Products.Add(tmp); } }
public async void Load() { try { var restaurantId = _dataService.Restaurant.Id; var httpResponse = await ShowProgressAsync(async() => await _categoryRepository.GetCategoriesAsync(restaurantId)); if (httpResponse == null) { return; } if (httpResponse.IsSuccess) { ProductCategories.Clear(); foreach (var category in httpResponse.Value) { ProductCategories.Add(new CategoryWrapper(category)); } } else { await _dialogService.ShowMessageAsync(httpResponse.Message, httpResponse.Title); } } catch (Exception ex) { _logService.Write(ex); await _dialogService.ShowMessageAsync(ex.Message); } finally { ((DelegateCommand)RefreshCommand).RaiseCanExecuteChanged(); ((DelegateCommand)NewCategoryCommand).RaiseCanExecuteChanged(); } }
/// <summary> /// Add created product category to database /// </summary> /// <param name="pc"></param> public void AddProductCategory(ProductCategory pc) { ProductCategories.Add(pc); db.ProductCategory.Add(pc); db.SaveChanges(); }