Beispiel #1
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.UserName, Email = model.Email
                };

                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    TempData["LoginCredentials"] = "Your Login credentials are as Follows";
                    TempData["UserName"]         = "******" + model.UserName;
                    TempData["Password"]         = "******" + model.Password;

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

                    string identifier = user.Id.ToString();
                    register.SaveUsersOnRegister(model.FirstName, model.LastName, identifier, model.Email, model.Phonenumber, model.Address, false);
                    EmailServices mail    = new EmailServices();
                    string        message = string.Format("<div><p>Hello Admin</P><p>Please be informed that a new vendor has signed up on findus.com with the follwing details</P><ul><li>Surname:{0}</li><li>FirstName:{1}</li><li>Contact Phone Number:{2}</li><li>Contact Person Address:{3}</li><li>Email:{4}</li></ul><button><a href='http://localhost:17750/Admin/ApproveByEmail?UserId={5}'>Approve</a></button><button><a href='http://findus.somee.com/Admin/DenyByEmail?UserId={5}'>Deny</a></button></div>", model.LastName, model.FirstName, model.Phonenumber, model.Address, model.Email, identifier);
                    mail.ToAdminEmail(message);
                    Session["Success"] = "Registration Sucessful.Please wait a bit for approval from the Admin and Please check your mail.";

                    //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("ProfileSetup", "ProfileSetup"));
                }
                AddErrors(result);
            }

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