Beispiel #1
0
 public static ReportsLogic GetInstance()
 {
     if (reportsLogic == null)
     {
         reportsLogic = new ReportsLogic();
     }
     return(reportsLogic);
 }
        public async void UpdateCountAsync(int id, int count)
        {
            int index = listProducts.IndexOf(GetElementById(id));

            listProducts[index].Count = count;
            if (count <= 10)
            {
                ReportsLogic.GetInstance().AddNewProductInReport(listProducts[index]);
            }
            await Task.Run(UpdateCountDb);
        }
        private void UpdateCountDb(List <int> idList, List <int> countProducts)
        {
            int index = 0;

            foreach (var id in idList)
            {
                Product product = internetMarketContext.Products.Find(id);
                product.Count = countProducts[index];
                if (countProducts[index] <= 10)
                {
                    ReportsLogic.GetInstance().AddNewProductInReport(product);
                }
                internetMarketContext.SaveChanges();
                index++;
            }
        }