Пример #1
0
 public static PortfolioPath[] CalculateMonteCarlo(MonteCarloViewModel fullMonte, ApplicationUser user )
 {
     int yearsUntilRetirement = fullMonte.PreferredRetirementAge - (DateTime.Now.Year - user.DateOfBirth.Year);
     int steps = yearsUntilRetirement + fullMonte.EstimatedRetirementSpan;
     const int nPaths = 250000;
     PortfolioViewModel p = fullMonte.PortfolioViewModel;
     PortfolioPath[] paths = MonteCarlo.RunSimulation(yearsUntilRetirement, nPaths, p.ExpectedReturnDouble, (double)p.Variance, (double)p.DollarValue, fullMonte.AnnualContribution, fullMonte.AnnualRetirementIncomeDraw, fullMonte.EstimatedRetirementSpan);
     return paths;
 }
Пример #2
0
 public async Task<IActionResult> Register(RegisterViewModel model)
 {
     if (ModelState.IsValid)
     {
         var user = new ApplicationUser
         {
             UserName = model.Email,
             Email = model.Email,
             FirstName = model.FirstName,
             LastName = model.LastName,
             DateOfBirth = model.DateOfBirth,
             RiskTolerance = model.RiskTolerance
         };
         var result = await _userManager.CreateAsync(user, model.Password);
         if (result.Succeeded)
         {
             string code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
             string callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme);
             await _emailSender.SendEmailAsync(model.Email, "Confirm your account",
                 "Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>");
             //await _signInManager.SignInAsync(user, isPersistent: false);
             _logger.LogInformation(3, "User created a new account with password.");
             return RedirectToAction(nameof(HomeController.Index), "Home"); // Need to change to have our own Confirmation notification page
         }
         AddErrors(result);
     }
     // If we got this far, something failed, redisplay form
     return View(model);
 }
Пример #3
0
        public async Task<IActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl = null)
        {
            if (User.IsSignedIn())
            {
                return RedirectToAction(nameof(ManageController.Index), "Manage");
            }

            if (ModelState.IsValid)
            {
                // Get the information about the user from the external login provider
                var info = await _signInManager.GetExternalLoginInfoAsync();
                if (info == null)
                {
                    return View("ExternalLoginFailure");
                }
                var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
                var result = await _userManager.CreateAsync(user);
                if (result.Succeeded)
                {
                    result = await _userManager.AddLoginAsync(user, info);
                    if (result.Succeeded)
                    {
                        await _signInManager.SignInAsync(user, isPersistent: false);
                        _logger.LogInformation(6, "User created an account using {Name} provider.", info.LoginProvider);
                        return RedirectToLocal(returnUrl);
                    }
                }
                AddErrors(result);
            }

            ViewData["ReturnUrl"] = returnUrl;
            return View(model);
        }
Пример #4
-1
 private async static void InitializeUserAdmin(ApplicationDbContext context, UserManager<ApplicationUser> userManager)
 {
     ApplicationUser admin = new ApplicationUser
     {
         UserName = "******",
         Email = "*****@*****.**",
         DateOfBirth = new DateTime(1990, 1, 1),
         EmailConfirmed = true
     };
     Thread.Sleep(2000);
     await userManager.CreateAsync(admin, "Beast@2"); //password must match constraints of 6 char min, case-change, min 1 number and non-letter character
     Thread.Sleep(2000);
     await userManager.AddToRoleAsync(admin, "admin");
     context.SaveChanges();
 }