public async Task <FreshAccount> AddFreshAccountAsync(FreshAccount freshAccount)
        {
            _context.FreshAccounts.Add(freshAccount);
            await _context.SaveChangesAsync();

            return(freshAccount);
        }
        public async Task UpdateFreshAccountAsync(FreshAccount freshAccount)
        {
            if (!AccountValidator.ValidateDefault(freshAccount))
            {
                throw new InvalidOperationException(Resources.FreshAccValidFailString);
            }

            await _freshAccountsRepository.UpdateFreshAccountAsync(freshAccount);
        }
        public async Task <FreshAccount> CreateNewFreshAccountAsync(FreshAccount freshAccount)
        {
            if (!AccountValidator.ValidateDefault(freshAccount))
            {
                throw new InvalidOperationException(Resources.FreshAccValidFailString);
            }

            return(await _freshAccountsRepository.AddFreshAccountAsync(freshAccount));
        }
Example #4
0
        public async Task <ActionResult> CreateFreshAccount([FromBody] FreshAccount freshAccount)
        {
            try
            {
                FreshAccount insertedAccount = await _freshAccountService.CreateNewFreshAccountAsync(freshAccount);

                return(Ok(insertedAccount));
            }
            catch (InvalidOperationException ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public async Task UpdateFreshAccountAsync(FreshAccount freshAccount)
        {
            var exists = await _context.FreshAccounts.AnyAsync(f => f.FreshAccountId == freshAccount.FreshAccountId);

            if (exists)
            {
                _context.FreshAccounts.Update(freshAccount);
                await _context.SaveChangesAsync();
            }
            else
            {
                throw new InvalidOperationException(Resources.FreshAccNotExistString);
            }
        }
Example #6
0
        public async Task <ActionResult> UpdateFreshAccount(int id, [FromBody] FreshAccount freshAccount)
        {
            freshAccount.FreshAccountId = id;
            try
            {
                await _freshAccountService.UpdateFreshAccountAsync(freshAccount);

                return(Ok());
            }
            catch (InvalidOperationException ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Example #7
0
        public void Seed()
        {
            var bot1 = new Bot()
            {
                BotId  = 1,
                Config = new Config()
            };

            var bot2 = new Bot()
            {
                BotId  = 2,
                Config = new Config()
                {
                    OverwriteConfig = false, NoActionTimeout = 1200
                },
                BotOrder = BotOrder.Start
            };

            _context.Bots.Add(bot1);
            _context.Bots.Add(bot2);
            _context.SaveChanges();

            var account1 = new Account()
            {
                Bot           = bot1,
                Login         = "******",
                Password      = "******",
                BirthDate     = new DateTime(1994, 11, 13),
                Region        = Region.Eune,
                Level         = 12,
                ExpPercentage = 57
            };

            var account2 = new Account()
            {
                Bot           = bot1,
                Login         = "******",
                Password      = "******",
                BirthDate     = new DateTime(1999, 4, 23),
                Region        = Region.Eune,
                Level         = 26,
                ExpPercentage = 7
            };

            var account3 = new Account()
            {
                Bot           = bot2,
                Login         = "******",
                Password      = "******",
                BirthDate     = new DateTime(1997, 7, 28),
                Region        = Region.Euw,
                Level         = 18,
                ExpPercentage = 84
            };

            _context.Accounts.Add(account1);
            _context.Accounts.Add(account2);
            _context.Accounts.Add(account3);
            _context.SaveChanges();

            var freshAcc1 = new FreshAccount()
            {
                Login     = "******",
                Password  = "******",
                BirthDate = new DateTime(1997, 12, 21),
                Region    = Region.Euw,
            };

            var freshAcc2 = new FreshAccount()
            {
                Login     = "******",
                Password  = "******",
                BirthDate = new DateTime(1994, 4, 3),
                Region    = Region.Eune,
            };

            var freshAcc3 = new FreshAccount()
            {
                Login     = "******",
                Password  = "******",
                BirthDate = new DateTime(1998, 11, 6),
                Region    = Region.Na,
            };

            var freshAcc4 = new FreshAccount()
            {
                Login     = "******",
                Password  = "******",
                BirthDate = new DateTime(1992, 5, 18),
                Region    = Region.Eune,
            };

            _context.FreshAccounts.Add(freshAcc1);
            _context.FreshAccounts.Add(freshAcc2);
            _context.FreshAccounts.Add(freshAcc3);
            _context.FreshAccounts.Add(freshAcc4);
            _context.SaveChanges();

            var rdyAcc1 = new ReadyAccount()
            {
                Login     = "******",
                Password  = "******",
                BirthDate = new DateTime(1995, 11, 22),
                Region    = Region.Eune,
            };

            var rdyAcc2 = new ReadyAccount()
            {
                Login     = "******",
                Password  = "******",
                BirthDate = new DateTime(1997, 4, 20),
                Region    = Region.Eune,
            };

            var rdyAcc3 = new ReadyAccount()
            {
                Login     = "******",
                Password  = "******",
                BirthDate = new DateTime(1995, 2, 21),
                Region    = Region.Euw,
            };

            var rdyAcc4 = new ReadyAccount()
            {
                Login     = "******",
                Password  = "******",
                BirthDate = new DateTime(1991, 2, 12),
                Region    = Region.Eune,
            };

            _context.ReadyAccounts.Add(rdyAcc1);
            _context.ReadyAccounts.Add(rdyAcc2);
            _context.ReadyAccounts.Add(rdyAcc3);
            _context.ReadyAccounts.Add(rdyAcc4);
            _context.SaveChanges();

            var log1 = new Log()
            {
                Bot    = bot1,
                Date   = new DateTime(2019, 07, 20, 15, 20, 34),
                Status = "Launching league"
            };

            var log2 = new Log()
            {
                Bot    = bot1,
                Date   = new DateTime(2019, 07, 20, 15, 20, 50),
                Status = "Logging in"
            };

            var log3 = new Log()
            {
                Bot    = bot1,
                Date   = new DateTime(2019, 07, 20, 15, 21, 03),
                Status = "Queueing up"
            };

            var log4 = new Log()
            {
                Bot    = bot1,
                Date   = new DateTime(2019, 07, 20, 15, 22, 26),
                Status = "Picking champion"
            };

            var log5 = new Log()
            {
                Bot    = bot1,
                Date   = new DateTime(2019, 07, 20, 15, 24, 11),
                Status = "Starting game script"
            };

            var log6 = new Log()
            {
                Bot    = bot2,
                Date   = new DateTime(2019, 07, 20, 17, 06, 15),
                Status = "Active game detected"
            };

            var log7 = new Log()
            {
                Bot    = bot2,
                Date   = new DateTime(2019, 07, 20, 17, 06, 34),
                Status = "Launching script"
            };

            var log8 = new Log()
            {
                Bot    = bot2,
                Date   = new DateTime(2019, 07, 20, 17, 08, 28),
                Status = "Enemy champion detected"
            };

            var log9 = new Log()
            {
                Bot    = bot2,
                Date   = new DateTime(2019, 07, 20, 17, 09, 44),
                Status = "Bot is low hp. Recalling..."
            };

            var logList = new List <Log>()
            {
                log1, log2, log3, log4, log5, log6, log7, log8, log9
            };

            foreach (var log in logList)
            {
                _context.Logs.Add(log);
            }
            _context.SaveChanges();
        }
 public static bool ValidateDefault(FreshAccount freshAccount)
 {
     return(ValidateDefault(new Account {
         Login = freshAccount.Login, Password = freshAccount.Password, BirthDate = freshAccount.BirthDate
     }));
 }