Esempio n. 1
0
        public static void AdminProcedure(LottoService lottoService)
        {
            Console.WriteLine("Please select:");
            Console.WriteLine("1. Start the draw");
            Console.WriteLine("2. List all winners by round");

            string inputChoice = Console.ReadLine();

            if (!int.TryParse(inputChoice, out int choice) || choice < 1 || choice > 2)
            {
                throw new Exception("Invalid choice.");
            }

            if (choice == 1)
            {
                Console.WriteLine("Draw started.");
                Round completedRound = lottoService.Draw();
                PrintRoundDetails(completedRound);
            }
            else
            {
                foreach (var round in DataHelper.LottoOrganization.Rounds.Where(x => x.WiningNumbers.Any())
                         .OrderBy(x => x.RoundNumber))
                {
                    PrintRoundDetails(round);
                }
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            LottoService  lottoService  = new LottoService();
            UserService   userService   = new UserService();
            TicketService ticketService = new TicketService();

            lottoService.CreateNewLottoOrganization("Lotarija na Makedonija");
            userService.AddNewUser("Risto", "LM0001");
            userService.AddNewUser("Darko", "LM0002");
            userService.AddNewUser("Admin", "admin");

            while (true)
            {
                try
                {
                    Console.WriteLine($"Welcome to {DataHelper.LottoOrganization.Name}!");
                    Console.WriteLine("Please login entering your card number:");
                    string inputCard = Console.ReadLine();

                    User loggedUser = userService.Login(inputCard);

                    Console.WriteLine($"Welcome {loggedUser.Username}!");

                    if (loggedUser.CardNumber == "admin")
                    {
                        AdminProcedure(lottoService);
                    }
                    else
                    {
                        UserProcedure(loggedUser, ticketService);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    Console.WriteLine("Thank you!");
                    Console.WriteLine("Log out......");
                    Thread.Sleep(5000);
                    Console.Clear();
                }
            }
        }
Esempio n. 3
0
        static async Task Main(string[] args)
        {
            var lottoService = new LottoService();

            var drawResults = new List <DrawResult>();

            var baseUrl        = "http://lottoresults.co.nz";
            var baseArchiveUrl = "/lotto/archive";

            //Step 1 - Get URLs of each previous month
            var archiveUrls = await lottoService.GetArchives(string.Concat(baseUrl, baseArchiveUrl));

            foreach (var archiveUrl in archiveUrls)
            {
                //Step 2 - Foreach previous month get all the draws for that month
                _monthlyDraws = await lottoService.GetMonthlyDraws(string.Concat(baseUrl, archiveUrl));

                // Foreach draw
                // Get draw date
                // Get Jackpot
                // Get Lotto Numbers
                // Strike Numbers?
                foreach (var draw in _monthlyDraws)
                {
                    //Step 5 - Get the Lotto numbers
                    var results = await lottoService.GetLottoNumbers(draw);

                    if (results != null)
                    {
                        drawResults.AddRange(results);
                    }
                }
            }

            foreach (var drawResult in drawResults)
            {
                await PrintDrawResults(drawResult);
            }

            Console.WriteLine("Finished");
        }