Exemplo n.º 1
0
        public void saveClientInfo(ClientInterestViewModel clientInterestViewModel)
        {
            Client client = new Client();

            client.UserId    = clientInterestViewModel.userId;
            client.UserName  = clientInterestViewModel.userName;
            client.gender    = clientInterestViewModel.gender;
            client.email     = clientInterestViewModel.email;
            client.country   = clientInterestViewModel.country;
            client.province  = clientInterestViewModel.province;
            client.city      = clientInterestViewModel.city;
            client.birthdate = clientInterestViewModel.birthdate;
            client.latitude  = clientInterestViewModel.latitude;
            client.longitude = clientInterestViewModel.longitude;

            db.Clients.Add(client);
            db.SaveChanges();

            foreach (string interest in clientInterestViewModel.interests)
            {
                ClientInterest clientInterest = new ClientInterest();
                clientInterest.UserName = clientInterestViewModel.userName;
                clientInterest.interest = interest;
                db.ClientInterests.Add(clientInterest);
            }

            db.SaveChanges();
        }
        public ActionResult CompleteInfo(string userName, string email, string id)
        {
            ViewBag.email    = email;
            ViewBag.username = userName;
            ViewBag.id       = id;
            ClientInterestViewModel user = repo.getClientInterest(id);

            return(View(user));
        }
Exemplo n.º 3
0
        public ClientInterestViewModel getClientInterest(string id)
        {
            AspNetUser User = (from i in db.AspNetUsers
                               where i.Id == id
                               select i).FirstOrDefault();
            ClientInterestViewModel ClientInterest = new ClientInterestViewModel();

            ClientInterest.email     = User.Email;
            ClientInterest.userId    = User.Id;
            ClientInterest.userName  = User.UserName;
            ClientInterest.interests = (from i in db.Interests
                                        select i.interest1).ToList();
            return(ClientInterest);
        }
        public ActionResult CompleteInfo(ClientInterestViewModel client)
        {
            repo.saveClientInfo(client);

            var userStore = new UserStore <IdentityUser>();
            UserManager <IdentityUser> manager = new UserManager <IdentityUser>(userStore);

            CreateTokenProvider(manager, EMAIL_CONFIRMATION);

            var user = manager.FindByName(client.userName);
            var code = manager.GenerateEmailConfirmationToken(user.Id);

            var callbackUrl = Url.Action("ConfirmEmail", "Home",
                                         new { userId = user.Id, code = code },
                                         protocol: Request.Url.Scheme);

            string emailBody = "Please confirm your account by clicking this link: <a href=\""
                               + callbackUrl + "\">Confirm Registration</a>";

            MailHelper mailer = new MailHelper();

            string Subject  = "Confirm registration";
            string response = mailer.EmailFromArvixe(
                new Message(client.email, Subject, emailBody));

            if (response.IndexOf("Success") >= 0)
            {
                //   ViewBag.Message = "A confirm email has been sent. Please check your email.";
                TempData["Message"] = "A confirm email has been sent. Please check your email.";
                return(RedirectToAction("CompleteRegistration"));
            }
            else
            {
                ViewBag.Message = response;
            }

            ClientInterestViewModel newClient = repo.getClientInterest(client.userId);

            return(View(newClient));
            // return RedirectToAction("UserProfile", new { userName = client.userName});
        }