Example #1
0
        public async Task <Authentification> LoginAsync()
        {
            if (auth.CountOfBadLogin == 3)
            {
                Console.WriteLine("You're been blocked for too many try to login");
                return(null);
            }
            Console.WriteLine("Login: "******"Password: "******"/login", user);

            if (isSuccess)
            {
                auth.AuthUser = user;
                PersonalStatistic personalStatistic = new PersonalStatistic(auth);
                var stats = await personalStatistic.GetStatsAsync(user);

                stat = JsonConvert.DeserializeObject <PlayerPersonalStat>(stats);
                if (stat == null)
                {
                    stat = new PlayerPersonalStat()
                    {
                        Login          = user.Login,
                        TimeInGame     = "00:00:00",
                        ChangesWinrate = new Dictionary <DateTime, float>()
                    }
                }
                ;
                auth.Stat = stat;
                //Console.WriteLine("You successfuly loged in");
                return(auth);
            }
            Console.WriteLine("\nYou enterd wrong login or password");
            Console.WriteLine("Press any button to go back to main menu");
            Console.ReadKey();
            return(null);
        }
    }
Example #2
0
        public async Task <bool> RegisterAsync()
        {
            Console.WriteLine("Login: "******"Password: "******"\nLogin length mast be more than 4!");
                Console.ReadKey();
                return(false);
            }
            if (password.Length < 6)
            {
                Console.WriteLine("\nPassword length must be 6 or more!");
                Console.ReadKey();
                return(false);
            }

            User user = new User()
            {
                Login = login, Password = password
            };

            bool isRegistered = await auth.AuthPostAsync("/registration", user);

            if (isRegistered)
            {
                Console.WriteLine("You successfuly registered");
            }
            else
            {
                Console.WriteLine("\nYou enterd wrong login or password");
            }
            Console.WriteLine("Press any button to go back to main menu");
            Console.ReadKey();
            return(true);
        }