public async Task<ActionResult> Register(RegisterViewModel model)
        {
            var timeout = this.GetTimeoutToken();

            var validationContext = new ValidationContext();
            model.Validate(validationContext);
            if (validationContext.HasErrors)
            {
                this.AddModelStateError(validationContext);
                return await this.View(model, timeout);
            }

            var account = new Account
            {
                IdentityType = IdentityType.EmailAddress,
                IdentityValue = model.EmailAddress.Trim().ToLowerInvariant(),
                CreationTime = Clock.UtcNow,
                Name = model.Name.Trim(),
                PasswordHash = BCrypt.Net.BCrypt.HashPassword(model.Password),
            };

            try
            {
                await this.accountStore.Insert(account, this.GetTimeoutToken());
                await this.CreateNewSession(account, false, timeout);
                return this.RedirectToAction("Index", "Home");
            }
            catch (DuplicateKeyException)
            {
                validationContext.AddError(nameof(model.EmailAddress), "This email address is already in use.");
                this.AddModelStateError(validationContext);
                return await this.View(model, timeout);
            }
        }
        public async Task<ActionResult> Register()
        {
            var timeout = this.GetTimeoutToken();
            if (await this.GetSession(timeout) != null)
            {
                return this.RedirectToAction("Index", "Home");
            }

            var model = new RegisterViewModel();
            return await this.View(model, timeout);
        }