예제 #1
0
        public ActionResult ClosetheDay()
        {
            try
            {
                // It checks if all tables on the system are empty
                if (soldProductsData.GetAll().Count < 1)
                {
                    List <ISaleModel> sales = saleData.GetSaleList();

                    // Checks if there are sold products on this day
                    if (sales.Count < 1)
                    {
                        log.Info("User tried to close the day without sold products");
                        return(View("NoSoldProducts"));
                    }

                    DateTime time  = DateTime.Now;
                    string   day   = time.ToString("dd-MM-yyyy");
                    string   hours = time.ToString("HH:mm");

                    decimal money = sales.Sum(x => x.Price);

                    try
                    {
                        // Creates and adds data to files about time, money income and list of sold products
                        ReadWriteFiles.AddFileOfTodaySoldProducts(sales, time);
                        ReadWriteFiles.WriteInDailyIncomeFile(day, hours, money);
                    }
                    catch (Exception exFile)
                    {
                        log.Error("Could't write to files", exFile);
                        return(View("ErrorWriteToFile"));
                    }

                    // Deletes all list of sold products on this day from database
                    saleData.EraseDataFromSaleList();

                    return(RedirectToAction("Menu"));
                }
                else
                {
                    log.Info("User tried to close the day with opened tables");
                    return(View("OpenedTables"));
                }
            }
            catch (Exception ex)
            {
                log.Error("Could't load data from Database", ex);
                return(View("ErrorRetriveData"));
            }
        }
예제 #2
0
 // GET: api/SoldProducts
 public List <ISoldProductModel> Get()
 {
     return(soldProductData.GetAll());
 }