Exemple #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Washes!");
            WashContext context = new WashContext();

            List <Wash> paidWashes   = context.Washes.Where(w => w.ReceiptID != null).ToList();
            List <Wash> unpaidWashes = context.Washes.Where(w => w.ReceiptID == null).ToList();


            Console.WriteLine($"Paid washes, Amount: {paidWashes.Count}");
            foreach (Wash wash in paidWashes)
            {
                Console.WriteLine($"Date: {wash.Date.ToString()}\tPrice: {wash.Price}");
            }

            Console.WriteLine($"\n\nUnpaid washes, Amount: {unpaidWashes.Count}");
            foreach (Wash wash in unpaidWashes)
            {
                Console.WriteLine($"Date: {wash.Date.ToString()}\tPrice: {wash.Price}");
            }

            Console.WriteLine("\n\nReceipts: ");
            List <Receipt> receipts = context.Receipts.Include(r => r.Washes).ToList();

            foreach (Receipt receipt in receipts)
            {
                Console.WriteLine($"Receipt paid {receipt.Date}\nContains washes:");
                foreach (Wash wash in receipt.Washes)
                {
                    Console.WriteLine($"Date: {wash.Date.ToString()}\tPrice: {wash.Price}");
                }

                Console.WriteLine($"Total: {receipt.Total}");
            }
        }
Exemple #2
0
        public TimeTableViewModel()
        {
            var             db       = new WashContext();
            List <WashTime> times    = db.WashTimes.Where(x => x.Time.Year == DateTime.Today.Year).ToList();
            List <WashTime> thisWeek =
                times.Where(
                    time =>
                    HelperFunctions.GetIso8601WeekOfYear(time.Time) ==
                    HelperFunctions.GetIso8601WeekOfYear(DateTime.Today)
                    ).OrderBy(f => f.Time.Date).ThenBy(f => f.Time.Hour).ThenBy(f => f.Machine
                                                                                ).GroupBy(
                    f => new { f.Time.Date, f.Time.Hour, f.Machine }
                    ).Select(
                    group => group.First()
                    ).ToList();

            if (thisWeek.Count < (126 * 2))
            {
                FillWeek();
                times    = db.WashTimes.Where(x => x.Time.Year == DateTime.Today.Year).ToList();
                thisWeek =
                    times.Where(
                        time =>
                        HelperFunctions.GetIso8601WeekOfYear(time.Time) ==
                        HelperFunctions.GetIso8601WeekOfYear(DateTime.Today)).ToList();
            }

            WeekNumber = HelperFunctions.GetIso8601WeekOfYear(DateTime.Now);
        }
        public MainWindow()
        {
            InitializeComponent();
            WashContext context = new WashContext();

            context.Washes.Add(new Wash {
                Date = DateTime.Now, Price = 10
            });
            context.SaveChanges();
        }
Exemple #4
0
        private void FillWeek(DateTime day, WashContext db)
        {
            DateTime firstdayInWeek = HelperFunctions.GetFirstDayOfWeek(day, CultureInfo.CurrentCulture);

            for (int i = 0; i < 7; i++)
            {
                filler.FillDay(firstdayInWeek.AddDays(i), "Left");
                filler.FillDay(firstdayInWeek.AddDays(i), "Right");
            }
        }
Exemple #5
0
        public TimeTableViewModel(DateTime day)
        {
            WeekNumber = HelperFunctions.GetIso8601WeekOfYear(day);
            var             db       = new WashContext();
            List <WashTime> times    = db.WashTimes.Where(x => x.Time.Year == day.Year).ToList();
            List <WashTime> thisWeek =
                times.Where(
                    time =>
                    HelperFunctions.GetIso8601WeekOfYear(time.Time) ==
                    HelperFunctions.GetIso8601WeekOfYear(DateTime.Today)
                    ).OrderBy(f => f.Time.Date).ThenBy(f => f.Time.Hour).ThenBy(f => f.Machine
                                                                                ).GroupBy(
                    f => new { f.Time.Date, f.Time.Hour, f.Machine }
                    ).Select(
                    group => group.First()
                    ).ToList();

            if (thisWeek.Count < (126 * 2))
            {
                FillWeek(day, db);
                times    = db.WashTimes.Where(x => x.Time.Year == day.Year).ToList();
                thisWeek =
                    times.Where(
                        time =>
                        HelperFunctions.GetIso8601WeekOfYear(time.Time) ==
                        HelperFunctions.GetIso8601WeekOfYear(DateTime.Today)
                        ).OrderBy(f => f.Time.Date).ThenBy(f => f.Time.Hour).ThenBy(f => f.Machine
                                                                                    ).GroupBy(
                        f => new { f.Time.Date, f.Time.Hour, f.Machine }
                        ).Select(
                        group => group.First()
                        ).ToList();
            }

            Monday    = new WashDayViewModel(thisWeek.GetRange(0, 36));
            Tuesday   = new WashDayViewModel(thisWeek.GetRange(35, 36));
            Wednesday = new WashDayViewModel(thisWeek.GetRange(71, 36));
            Thursday  = new WashDayViewModel(thisWeek.GetRange(107, 36));
            Friday    = new WashDayViewModel(thisWeek.GetRange(143, 36));
            Saturday  = new WashDayViewModel(thisWeek.GetRange(179, 36));
            Sunday    = new WashDayViewModel(thisWeek.GetRange(215, 36));
        }