public void Delete(Product product) { this.RemoveCoupons(product); this.Products.Remove(product); this.CalculatePrice(); }
public static Product Check(string barcode, Product mainProduct, IEnumerable<Product> products) { if (mainProduct.Barcodes.Any(x => x.Value == barcode)) { return mainProduct; } var existingProduct = products.FirstOrDefault(x => x.Barcodes.Any(y => y.Value == barcode)); return existingProduct; }
public ProductViewModel(Product product) { this.Product = product; this.OldName = product.Name; this.SellingPrice = product.SellingPrice.ToString(); this.BuyingPrice = product.BuyingPrice.ToString(); this.DeleteBarcodeCommand = new RelayCommand<Barcode>(this.HandleDeleteBarcodeCommand); this.DeleteExpirationDateCommand = new RelayCommand<ExpirationDate>(this.HandleDeleteExpirationDateCommand); this.AddExpirationDateCommand = new RelayCommand(this.HandleAddExpirationDateCommand, this.CanAddExpirationDate); }
private void RemoveCoupons(Product product) { if (product.Name.Contains("хляб") && !product.Name.Contains("$")) { var coupons = this.Products.Where(x => x.Name.Contains("$")).ToList(); foreach (var coupon in coupons) { this.Products.Remove(coupon); } } }
public void Add(Product product) { var existingProduct = this.Products.FirstOrDefault(x => x.Id == product.Id); if (existingProduct != null) { this.Products.Remove(existingProduct); } this.RemoveCoupons(product); this.Products.Add(product); this.CalculatePrice(); }
public ProductInformationViewModel(IServerManager manager, Product selectedProduct, IEnumerable<Product> products) { this.manager = manager; this.products = products; this.MainProductViewModel = new ProductViewModel(selectedProduct.DeepClone()); this.Save = new RelayCommand(this.HandleSave, this.CanSave); this.Cancel = new RelayCommand(this.HandleCancel); this.ProductInAllServers = new Dictionary<ServerInformation, ProductViewModel>(); foreach (var pair in this.manager.Cache.ProductsPerServer) { var product = pair.Value.FirstOrDefault(x => x.Name == selectedProduct.Name); var productViewModel = new ProductViewModel(product ?? new Product()); this.ProductInAllServers.Add(pair.Key, productViewModel); } }