public AddProductParametrVM()
        {
            SelectedProduct = new Entity.Product();
            SelectedProduct.ProductType = new ProductType();
            SelectedProductParameter = new ProductParametr();

            surrogateProduct = new Surrogate<Entity.Product>(new ProductServiceProxy());
            Products = surrogateProduct.Deserialize(surrogateProduct.GetAll());

            surrogateProductParameter = new Surrogate<ProductParametr>(new ProductParameterServiceProxy());
            Products = surrogateProduct.Deserialize(surrogateProductParameter.GetAll());

            ProductParametrs = new ObservableCollection<ProductParametr>(Products.Select(a => a.ProductType).ToList().FirstOrDefault().ProductParametrs.ToList());
        }
 //сделать проверку, на то что если парам
 //TODO: Сделать проверку если есть пустые параметры, без значений, - нужно фиксить
 public void AddProductParametrValue(ProductParametr productParametr, ProductParametrValue productParametrValue)
 {
     Console.WriteLine("+ You added value to parametr");
 }
 private void DeleteProductParameterToProducts(ProductParametr dpr)
 {
     foreach (var it in Products.Where(it => it.ProductTypeID == dpr.ProductType.Id))
     {
         it.ProductType.ProductParametrs.Remove(it.ProductType.ProductParametrs.ToList()
             .Where(a => a.Id == dpr.Id)
             .ToList().FirstOrDefault());
     }
     ProductParametrs.Remove(ProductParametrs
       .Where(param => param.Id == SelectedProductParameter.Id)
       .ToList().First());
 }
 /// <summary>
 /// // Two rows for adding productparametr to list in the view
 /// </summary>
 private void AddSelectedProductParametrToProducts(ProductParametr productParametr)
 {
     ProductParametrs.Add(productParametr);
     foreach (var it in Products)
     {
         if (productParametr.ProductType == null) { productParametr.ProductType = new ProductType(); }
         if (it.ProductTypeID == productParametr.ProductType.Id)
         {
             productParametr.ProductType = null;
             it.ProductType.ProductParametrs.Add(productParametr);
         }
     }
 }
Exemplo n.º 5
0
 public void AddProductParametrValue(ProductParametr productParametr, ProductParametrValue productParametrValue)
 {
     _state.AddProductParametrValue(productParametr, productParametrValue);
 }
Exemplo n.º 6
0
        public void FillDB()
        {
            using (MngPaycheckContext db = new MngPaycheckContext())
            {
                //WORK WITH PRODUCT
                Product prod = new Product()
                {
                    Name = "Asus",
                    Characteristicks = "Super laptop",
                    Cost = 1012,
                    Description = "It`s a super"
                };

                Product prod2 = new Product()
                {
                    Name = "Acer",
                    Characteristicks = "Super laptop",
                    Cost = 2016,
                    Description = "It`s a super"
                };

                ProductType prodType = new ProductType()
                {
                    Name = "Laptop",
                };

                ProductParametrValue productParametrValue = new ProductParametrValue(prod, "5 gb");
                ProductParametr productParametr = new ProductParametr()
                {
                    Name = "Ram",
                    ProductType = prodType,
                    ProductParametrValue = productParametrValue
                };

                prod.ProductType = prodType;

                db.Products.Add(prod);
                db.ProductTypes.Add(prodType);
                db.ProductParametrs.Add(productParametr);
                db.ProductParametrValues.Add(productParametrValue);
                db.SaveChanges();

                /////////WORK WITH PURCHASES
                ///////Create one purchase and added two products in this purchase
                ///
                ///
                ///
                ///
                //Create Buyer and add to Buyer purchase
                Buyer buyer = new Buyer()
                {
                    Name = "Andrew",
                    Login = "******",
                    Password = "******",
                };
                db.Buyers.Add(buyer);
                db.SaveChanges();

                Purchase purchase = new Purchase()
                {
                    Favorite = false,
                    PurchaseAdress = "123123213",
                    PurchaseDate = DateTime.Now,
                    SumPurchase = 100213,
                    PaymentType = new PaymentType() { Name = "Cash"},
                    Buyer = buyer
                };

                PurchaseProduct purchaseProduct = new PurchaseProduct()
                {
                    Cost = prod.Cost,
                    Units = 12,
                    Product = prod,
                    Purchase = purchase
                };

                PurchaseProduct purchaseProduct2 = new PurchaseProduct()
                {
                    Cost = prod2.Cost,
                    Product = prod2,
                    Purchase = purchase
                };

                db.PurchaseProducts.Add(purchaseProduct);
                db.PurchaseProducts.Add(purchaseProduct2);
                db.SaveChanges();
                //////////////////////

                PaymentType paytype = new PaymentType()
                {
                    Name = "Creditka"
                };

                purchase.PaymentType = paytype;

                db.PaymentTypes.Add(paytype);
                db.SaveChanges();

                foreach (var item in db.Buyers.Select(a=>a.Purchases).ToList())
                {
                    foreach (var it in item.Select(a=>a.Favorite))
                    {
                       Console.WriteLine(it.ToString());
                    }
                }

                //LogicsType<Purchase> payType = new LogicsType<Purchase>(new PaymentTypeStrategy());
                //foreach (var item in payType.Execute(paytype))//получаю список всех елементов, у которых тип == paytype
                //{
                //    Console.WriteLine(item.PurchaseAdress);
                //}

                //Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!!!");

                //LogicsType<Product> productType = new LogicsType<Product>(new ProductTypeStrategy());
                //foreach (var item in productType.Execute(prodType))
                //{
                //    Console.WriteLine(item.Name);
                //}
            }
            Console.WriteLine("OK!");
        }
 public void AddProductParametrValue(ProductParametr productParametr, ProductParametrValue productParametrValue)
 {
     Console.WriteLine("I'm sorry bro ! The first add product");
 }
 public void AddProductParametrValue(ProductParametr productParametr, ProductParametrValue productParametrValue)
 {
     Console.WriteLine("You added value of product parametr, please add the parametr of product");
 }