Example #1
0
        public ActionResult Create(ShareModel share)
        {
            //IEnumerable<ApplicationUserModel> usersWithShares = shareBPL.GetAllUsersWithShareHoldingSummary();
            IEnumerable<ShareModel> usersWithShares = shareBPL.GetShareTransactionHistoryForAllUser();
            SelectList users = accountBPL.GetUserSelectList(false);
            ViewBag.Users = users;
            ViewBag.UserShares = usersWithShares;

            if (!ModelState.IsValid)
                return View("Share", share);

            share.CreatedUserId = User.Identity.GetUserId();
            ShareModel addedShare = null;
            try
            {
                addedShare = shareBPL.AddShares(share);
                if (addedShare != null)
                {
                    EmailSender emailSender = new EmailSender();
                    emailSender.SendSharePurchaseInvoice(addedShare);
                }

                TempData["CreateStatus"] = "Success";
                return RedirectToAction("Share");
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = ex.Message;
            }

            return View("Share", share);
        }
Example #2
0
        public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(model.Email);
                if (user == null)
                {
                    // Don't reveal that the user does not exist or is not confirmed
                    return View("ForgotPasswordConfirmation");
                }

                // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                // Send an email with this link
                string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
                var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                EmailSender emailSender = new EmailSender();
                emailSender.SendForgotPasswordEmailAsync(model.Email, callbackUrl);
                return RedirectToAction("ForgotPasswordConfirmation", "Account");
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Example #3
0
        public async Task<ActionResult> Register(RegisterModel model)
        {
            ViewBag.StateList = GetStateSelectList();
            ViewBag.CountryList = commonBPL.GetCountrySelectList();
            if (ModelState.IsValid)
            {
                IdentityResult result = await accountBPL.RegisterUserAsync(model).ConfigureAwait(false);
                if (result.Succeeded)
                {
                    EmailSender emailSender = new EmailSender();
                    emailSender.SendRegistrationConfirmationEmail(model);

                    // await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return RedirectToAction("login", "account");
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }