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);
            }
        }
        private void GetExistingProduct(Product existingProduct)
        {
            this.MainProductViewModel = new ProductViewModel(existingProduct.DeepClone());

            var tempProductInAllServers = new Dictionary<ServerInformation, ProductViewModel>();
            foreach (var pair in this.manager.Cache.ProductsPerServer)
            {
                var product = pair.Value.FirstOrDefault(x => x.Name == this.Name);
                var productViewModel = new ProductViewModel(product ?? new Product());
                tempProductInAllServers.Add(pair.Key, productViewModel);
            }

            this.ProductInAllServers = tempProductInAllServers;
        }
        private void GetNewProduct(string name)
        {
            this.MainProductViewModel = new ProductViewModel(new Product { Name = name });

            var tempProductInAllServers = new Dictionary<ServerInformation, ProductViewModel>();
            foreach (var pair in this.manager.Cache.ProductsPerServer)
            {
                var productViewModel = new ProductViewModel(new Product());
                tempProductInAllServers.Add(pair.Key, productViewModel);
            }

            this.ProductInAllServers = tempProductInAllServers;
        }
        public void MapProperties(ProductViewModel baseProduct)
        {
            this.Product.Name = ProductNameFixer.Fix(baseProduct.Product.Name);
            this.Product.BuyingPrice = decimal.Parse(baseProduct.BuyingPrice);
            this.Product.SellingPrice = string.IsNullOrEmpty(this.SellingPrice) ? this.Product.SellingPrice : decimal.Parse(this.SellingPrice);
            this.Product.Measure = baseProduct.Product.Measure;
            this.Product.Barcodes = baseProduct.Product.Barcodes;

            this.Product.Quantity = this.Product.Quantity ?? 0;
            this.Product.Quantity += string.IsNullOrEmpty(this.QuantityToAdd) ? 0 : decimal.Parse(this.QuantityToAdd);
        }