Example #1
0
 public List <SUPPLY> AllSupplies()
 {
     try {
         return(supplyS.All());
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #2
0
        public decimal GetTotalSumMonthSupply(int month, int year)
        {
            try
            {
                using (StudioDB db = new StudioDB())
                {
                    var supplies = supplyS.All();
                    int idSupply = -1;
                    foreach (var item in supplies)
                    {
                        if (Parser.ParseStringToIntArray(item.delivery_date, '.')[1] == month &&
                            Parser.ParseStringToIntArray(item.delivery_date, '.')[2] == year)
                        {
                            idSupply = item.id_supply;
                        }
                    }

                    decimal res = 0;
                    if (idSupply != -1)
                    {
                        var products = db.PRODUCTs.Where(x => x.id_supply == idSupply);
                        foreach (var item in products)
                        {
                            res += DecrementPercentages(item.price, 10) * item.count;
                        }

                        var salesProducts = from b in db.BASKETs
                                            join p in db.PRODUCTs
                                            on b.id_product equals p.id_product
                                            where p.id_supply == idSupply
                                            select new { b.count, p.price };
                        foreach (var item in salesProducts)
                        {
                            res += DecrementPercentages(item.price, 10) * item.count;
                        }
                    }
                    return(res);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }