Ejemplo n.º 1
0
        public ActionResult Create(AccountViewModel accountViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // Check if the username exists
                    IEnumerable <Account> accounts = _accountRepo.GetAccountsByUsername(accountViewModel.Username);
                    if (accounts.Count() == 0)
                    {
                        var newAccount = new Account
                        {
                            Username   = accountViewModel.Username,
                            Passphrase = accountViewModel.Passphrase,
                            FirstName  = accountViewModel.FirstName,
                            LastName   = accountViewModel.LastName
                        };
                        _accountRepo.AddAccount(newAccount);
                        _accountRepo.Save();

                        return(RedirectToAction(nameof(SignIn)));
                    }
                    else
                    {
                        return(RedirectToAction(nameof(InvalidUsername)));
                    }
                }

                return(View(accountViewModel));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 2
0
        public IActionResult PostAccount(Account account)
        {
            if (AccountExists(account.Id))
            {
                _logger.LogWarning($"Account with id: {account.Id} already exists.");
                return(Conflict());
            }

            _accountRepo.AddAccount(account);
            _accountRepo.SaveChanges();

            _logger.LogInformation($"Account with id: {account.Id} has been added.");
            return(CreatedAtAction(nameof(GetAccount), new { id = account.Id }, account));
        }
Ejemplo n.º 3
0
        public async Task AddAccount(Int64 steamid)
        {
            Regex r = new Regex("^[0-9]{17}$");

            if (!r.Match(steamid.ToString()).Success)
            {
                await ReplyAsync("Invalid SteamId64. Please enter a valid one (e.g. 76561198029915406)");

                return;
            }

            Account acc = new Account()
            {
                SteamId      = steamid.ToString(),
                TimeOfReport = DateTime.Now,
                VACBanned    = false,
                ServerId     = Context.Guild.Id,
                ChannelId    = Context.Channel.Id,
                MessageId    = Context.Message.Id
            };

            try
            {
                bool exist = _steamRepo.validateAccount(acc);
                if (exist)
                {
                    _accRepo.AddAccount(acc);

                    string message = "User is now being tracked. \nUpdating tracked users...";
                    await ReplyAsync(message);

                    await UpdateVACStatus();
                }
            }
            catch (Exception e)
            {
                await ReplyAsync($"Error: {e.Message}");

                return;
            }
        }