public void CanAddInsureeUsingInsuranceAppContext()
        {
            var insuree = new Insuree
            {
                DateOfBirth = DateTime.Now,
                DateCreated = DateTime.Now,
                FirstName = "TestFirstName",
                LastName = "TestLastName",
                DateModified = DateTime.Now
            };

            var context = new InsuranceAppContext();
            context.Insurees.Add(insuree);
            context.SaveChanges();

            insuree.Id.Should().BeGreaterThan(0);
        }
        public void CanAddInsureeUsingInsuranceAppContext()
        {
            var insuree = new Insuree
            {
                DateOfBirth  = DateTime.Now,
                DateCreated  = DateTime.Now,
                FirstName    = "TestFirstName",
                LastName     = "TestLastName",
                DateModified = DateTime.Now
            };

            var context = new InsuranceAppContext();

            context.Insurees.Add(insuree);
            context.SaveChanges();

            insuree.Id.Should().BeGreaterThan(0);
        }
Esempio n. 3
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl = returnUrl ?? Url.Content("~/");
            if (ModelState.IsValid)
            {
                var user = new IdentityUser {
                    UserName = Input.Email, Email = Input.Email
                };
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { userId = user.Id, code = code },
                        protocol: Request.Scheme);

                    await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
                                                      $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                    await _signInManager.SignInAsync(user, isPersistent : false);

                    PolicyHolder newUser = new PolicyHolder();
                    newUser.Email     = user.Email;
                    newUser.Firstname = "First Name";
                    newUser.Lastname  = "Last Name";
                    _context.PolicyHolder.Add(newUser);
                    _context.SaveChanges();
                    return(LocalRedirect(returnUrl));
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
        public void CanExecuteQueryAgainstDataContext()
        {
            var lastName = Guid.NewGuid().ToString();
            var context = new InsuranceAppContext();

            var insuree = new Insuree
            {
                DateOfBirth = DateTime.Now,
                DateCreated = DateTime.Now,
                FirstName = "TestFirstName",
                LastName = lastName,
                DateModified = DateTime.Now
            };

            context.Insurees.Add(insuree);
            context.SaveChanges();

            var insureeCheck = context.Insurees.Single(x => x.LastName == lastName);
            insureeCheck.Should().NotBeNull();
        }
        public void CanExecuteQueryAgainstDataContext()
        {
            var lastName = Guid.NewGuid().ToString();
            var context  = new InsuranceAppContext();

            var insuree = new Insuree
            {
                DateOfBirth  = DateTime.Now,
                DateCreated  = DateTime.Now,
                FirstName    = "TestFirstName",
                LastName     = lastName,
                DateModified = DateTime.Now
            };

            context.Insurees.Add(insuree);
            context.SaveChanges();

            var insureeCheck = context.Insurees.Single(x => x.LastName == lastName);

            insureeCheck.Should().NotBeNull();
        }