public bool Add(MongoProduct prod)
 {
     if (!this.Contains(prod.ProductId))
     {
         this.products.Insert(prod);
         return true;
     }
     else
     {
         return false;
     }
 }
Example #2
0
 public bool Add(MongoProduct prod)
 {
     if (!this.Contains(prod.ProductId))
     {
         this.products.Insert(prod);
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public void AddProducts(IQueryable <SalesReport> reports)
        {
            var productIDs = reports.Select(x => x.ProductId).Distinct();

            foreach (var productId in productIDs)
            {
                var productSales = reports.Where(x => x.ProductId == productId);
                var currentProd  = entDb.Products.First(p => p.Id == productId);

                double  productQuantity = 0;
                decimal income          = 0;
                foreach (var sale in productSales)
                {
                    productQuantity += sale.Quantity;
                    income          += sale.Sum;
                }

                MongoProduct product = new MongoProduct((int)currentProd.OldId,
                                                        currentProd.ProductName, currentProd.Vendor.VendorName, productQuantity, income);

                this.products.Insert(product);
            }
        }
        public void AddProducts(IQueryable<SalesReport> reports)
        {
            var productIDs = reports.Select(x => x.ProductId).Distinct();

            foreach (var productId in productIDs)
            {
                var productSales = reports.Where(x => x.ProductId == productId);
                var currentProd = entDb.Products.First(p => p.Id == productId);

                double productQuantity = 0;
                decimal income = 0;
                foreach (var sale in productSales)
                {
                    productQuantity += sale.Quantity;
                    income += sale.Sum;
                }

                MongoProduct product = new MongoProduct((int)currentProd.OldId,
                    currentProd.ProductName, currentProd.Vendor.VendorName, productQuantity, income);

                this.products.Insert(product);
            }
        }