Example #1
0
        public static async Task <Account> AuthenticateAsync(SqlConnection connection, string accountName, string accountKey, ILogger log)
        {
            try
            {
                var qry = new ValidateAccount()
                {
                    Name = accountName,
                    Key  = accountKey
                };

                var result = await qry.ExecuteSingleOrDefaultAsync(connection);

                if (result == null)
                {
                    throw new Exception($"Account {qry.Name}:{qry.Key} not found.");
                }

                if (result.RenewalDate < DateTime.Now)
                {
                    throw new Exception($"Account expired as of {result.RenewalDate}");
                }

                return(result);
            }
            catch (Exception exc)
            {
                log?.LogError(exc, $"Error locating account: {exc.Message}");
                throw new Exception($"Error locating account: {exc.Message}");
            }
        }
Example #2
0
        public async Task <ValidateAccountResult> ValidateAccountAsync(RaiAddress acc)
        {
            var action  = new ValidateAccount(acc);
            var handler = new ActionHandler <ValidateAccount, ValidateAccountResult>(_node);

            return(await handler.Handle(action));
        }
Example #3
0
 public ActionResult Create(Account acc)
 {
     if (ValidateAccount.IsValid(acc))
     {
         acc.CompanyId = (int)Session["CompanyId"];
         ServiceFactory.GetAccountServices().Insert(acc);
         return(RedirectToAction("Index"));
     }
     else
     {
         ViewBag.Error = ValidateAccount.Message;
         return(View());
     }
 }