Esempio n. 1
0
        public void SendValidationCode(RegisteredUser user, string validateUri)
        {
            string confirmUrl = string.Format("{0}?userid={1}&code={2}", validateUri, user.MembershipUserId, user.RegistrationCode);

            RegisterData rd = new RegisterData();

            rd.ConfimationCode = user.RegistrationCode;
            rd.ConfirmUrl      = confirmUrl;
            rd.UserName        = user.UserName;

            messageSenderService.SendWithTemplate("confirmemail", user, rd, user.EmailAddress);
            messageSenderService.SendWithTemplate("aweberemail", user, user, ConfigurationManager.AppSettings["Mailing_Admin"]);
        }
        public ActionResult Validate(string userid, string code)
        {
            if (!string.IsNullOrEmpty(code) && !string.IsNullOrEmpty(userid))
            {
                int userId = Convert.ToInt32(userid);

                MembershipUser mu = Membership.GetUser(userId);
                if (mu != null)
                {
                    RegisteredUser ru = registeredUserRepository.GetByMembershipId(userId);

                    if (!mu.IsApproved)
                    {
                        // Make sure is using the valid code
                        if (ru != null && ru.RegistrationCode.Trim().ToLower() == code.Trim().ToLower())
                        {
                            // Approve on Membership
                            mu.IsApproved = true;
                            Membership.UpdateUser(mu);

                            // Approve on System
                            ru.Confirm();
                            ru.Closet.PrivacyLevel = PrivacyLevel.FullCloset;
                            registeredUserRepository.SaveOrUpdate(ru);
                            // Send approval mail
                            messageSenderService.SendWithTemplate("approvedmail", ru, ru.UserName, ru.EmailAddress);
                            return(RedirectToAction("Index", "Login", new { validatedUser = true }));
                        }
                    }
                    else
                    {
                        if (ru != null && ru.RegistrationCode.Trim().ToLower() == code.Trim().ToLower())
                        {
                            ru.EmailAddress = ru.NewMail;
                            mu.Email        = ru.EmailAddress;
                            ru.NewMail      = string.Empty;
                            registeredUserRepository.SaveOrUpdate(ru);
                            Membership.UpdateUser(mu);
                            // Send approval mail
                            messageSenderService.SendWithTemplate("approvedmail", ru, ru.UserName, ru.EmailAddress);
                            return(RedirectToAction("Index", "Home", new { validatedUser = true }));
                        }
                    }
                }
            }

            return(RedirectToAction("Index", new { invalidCode = true, userid = userid }));
        }
Esempio n. 3
0
        public ActionResult ForgotPassword(ForgotPasswordView view)
        {
            if (ModelState.IsValid)
            {
                MembershipUser mu = Membership.GetUser(view.UserName);

                if (mu != null)
                {
                    try
                    {
                        string newPassword = mu.ResetPassword(view.Answer);

                        PasswordEmailData ped = new PasswordEmailData();
                        ped.UserName    = mu.UserName;
                        ped.NewPassword = newPassword;
                        messageSender.SendWithTemplate("forgotpassword", null, ped, mu.Email);

                        TempData["Errors"] = "Your new password has been sent by email, please check your inbox.";
                        return(RedirectToAction("ForgotPassword"));
                    }
                    catch (MembershipPasswordException)
                    {
                        ModelState.AddModelError("Answer", "Your answer does not match with our records.");
                    }
                }
                else
                {
                    ModelState.AddModelError("UserName", "Your user name is not valid.");
                }
            }

            return(View(view));
        }
Esempio n. 4
0
 public ActionResult Index(FeedBack feedBack)
 {
     feedBack.Content = contentService.GetRandomStyleAlerts();
     feedBack.Message = HttpUtility.HtmlEncode(feedBack.Message);
     feedBack.Name    = HttpUtility.HtmlEncode(feedBack.Name);
     if (ModelState.IsValid)
     {
         foreach (string user in Roles.GetUsersInRole("Administrator"))
         {
             messageSenderService.SendWithTemplate("feedback", null, feedBack, Membership.GetUser(user).Email);
         }
         return(View("Thanks", contentService.GetRandomStyleAlerts()));
     }
     return(View(feedBack));
 }
Esempio n. 5
0
        public ActionResult Index(string emailAdress)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    InvitationCode invitationCode = _invitationCodeGeneratorService.Generate(emailAdress);
                    _messageSenderService.SendWithTemplate("InvitationRequest", null, invitationCode.Code, invitationCode.EmailAddress);
                    TempData["message"] = "We have just send you an invitation code to your email address. You can enter it here to start creating your closet!";
                    return(RedirectToAction("Index", "Home"));
                }
                catch (MailAlreadyExistsException)
                {
                    ModelState.AddModelError("emailAdress", "Email address already used.");
                }
            }

            return(View());
        }
        public void InviteUsers(BasicUser invitedBy, string comments, FriendProvider friendProvider, IList <IBasicUser> contacts, bool includeInvitationCode)
        {
            // Make sure we get the complete user.
            BasicUser user = basicUserRepository.Get(invitedBy.Id);

            // If we are including the invitation code is because we are in Beta, no more than 10 invites per user.
#if !DEBUG
            if (includeInvitationCode)
            {
                if (user.Friends.Count + contacts.Count >= MAX_TO_INVITE)
                {
                    if (MAX_TO_INVITE - user.Friends.Count > 0)
                    {
                        throw new LimitOfFriendsExceededException(string.Format("You can add up to {0} more friends in the Beta period.", MAX_TO_INVITE - user.Friends.Count));
                    }
                    else
                    {
                        throw new LimitOfFriendsExceededException(string.Format("You have reached the {0} contacts limit in the Beta period.", MAX_TO_INVITE));
                    }
                }
            }
#endif

            basicUserRepository.DbContext.BeginTransaction();
            foreach (IBasicUser contact in contacts)
            {
                if (contact.EmailAddress.Trim() == string.Empty || user.EmailAddress.Trim().ToLower() == contact.EmailAddress.Trim().ToLower())
                {
                    continue;
                }

                // Call the Friend Creator service
                Friend f = friendCreatorService.Create(contact.EmailAddress.Trim().ToLower(), contact.FirstName, contact.LastName, friendProvider);

                // Make sure it does not have it as a friend to send the email.
                if (!user.HasFriend(f))
                {
                    // Save the Friend into the user collection
                    f.BasicUser = user;
                    user.AddFriend(f);
                }

                // TODO: Review how to get the Url from the controller
                string     confirmUrl = string.Format("/Friend/InvitedMe/default.aspx");
                InviteData inviteData = new InviteData {
                    Friend = f, AcceptUrl = confirmUrl, InvitationCode = Guid.NewGuid().ToString()
                };

                if (f.User is InvitedUser)
                {
                    if (includeInvitationCode)
                    {
                        // Create an invitation code
                        InvitationCode ic = new InvitationCode();
                        ic.EmailAddress = f.User.EmailAddress;
                        ic.Code         = inviteData.InvitationCode;
                        ic.InvitedBy    = f.BasicUser;
                        invitationCodeRepository.SaveOrUpdate(ic);

                        messageSenderService.SendWithTemplate("invitation_with_code", user, inviteData, f.User.EmailAddress);
                    }
                    else
                    {
                        messageSenderService.SendWithTemplate("invitation", user, f, f.User.EmailAddress);
                    }
                }
                else
                {
                    messageSenderService.SendWithTemplate("acceptinvite", user, inviteData, f.User.EmailAddress);
                }
            }

            basicUserRepository.SaveOrUpdate(user);
            basicUserRepository.DbContext.CommitTransaction();
        }
Esempio n. 7
0
        public JsonResult InviteFriends(InviteFriends inviteFriends)
        {
            string[]       contacts = inviteFriends.FriendsEmails.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            RegisteredUser user     = registeredUserRepository.Get(this.UserId);

            ClosetOutfit co = closetOutfitRepository.Get(Convert.ToInt32(inviteFriends.OutfitId));

            foreach (string contact in contacts)
            {
                if (string.IsNullOrEmpty(contact) || contact == " ")
                {
                    continue;
                }

                string email = contact;
                if (contact.IndexOf("[") != -1 && contact.IndexOf("]") != -1)
                {
                    email = contact.Split('[')[1].Split(']')[0];
                }

                string key = Guid.NewGuid().ToString();

                List <Garment> lst = new List <Garment>();
                foreach (Garment garment in co.Components)
                {
                    if (garment.Id != 0)
                    {
                        lst.Add(garment);
                    }
                }

                EmailData data = new EmailData
                {
                    Components     = lst,
                    KeyCode        = key,
                    Comments       = HttpUtility.HtmlEncode(inviteFriends.Message),
                    InvitationLink = "/Outfit/Rating/VoteFromInvitation/" + key + "/default.aspx",
                    GarmentsUri    = Resources.GetGarmentLargePath(),
                    OutfitUpdater  = outfitUpdaterRepository.GetRandomOutfitUpdaterFor(co.PreCombination)
                };
                if (data.OutfitUpdater == null)
                {
                    data.OutfitUpdater          = new OutfitUpdater();
                    data.OutfitUpdater.BuyUrl   = string.Empty;
                    data.OutfitUpdater.ImageUrl = string.Empty;
                    data.OutfitUpdater.Name     = string.Empty;
                    data.OutfitUpdater.Partner  = new Partner(string.Empty, string.Empty);
                }
                data.OutfitUpdaterPrice = Convert.ToDecimal(data.OutfitUpdater.Price).ToString("$#,##0.00");

                messageSenderService.SendWithTemplate("invite2rate", user, data, email);

                FriendRatingInvitation invitation = new FriendRatingInvitation();
                invitation.FriendEmail      = email;
                invitation.InvitationSentOn = DateTime.Now;
                invitation.FriendRateOn     = invitation.InvitationSentOn;
                invitation.KeyCode          = key;
                invitation.Message          = inviteFriends.Message;
                invitation.User             = user;
                invitation.ClosetOutfit     = co;
                friendRatingInvitationRepository.DbContext.BeginTransaction();
                friendRatingInvitationRepository.SaveOrUpdate(invitation);
                friendRatingInvitationRepository.DbContext.CommitTransaction();
            }

            if (inviteFriends.SendMe)
            {
                EmailCopyData data = new EmailCopyData
                {
                    Components    = co.Components,
                    Comments      = HttpUtility.HtmlEncode(inviteFriends.Message),
                    GarmentsUri   = Resources.GetGarmentLargePath(),
                    OutfitUpdater = outfitUpdaterRepository.GetRandomOutfitUpdaterFor(co.PreCombination)
                };
                data.OutfitUpdaterPrice = Convert.ToDecimal(data.OutfitUpdater.Price).ToString("$#,##0.00");

                messageSenderService.SendWithTemplate("copyinvite2rate", user, data, user.EmailAddress);
            }

            TrackingHelper.Save("MyOutfitsController", "InviteFriends", Guid.NewGuid().ToString(), "noIp", UserId.ToString(), "noChannel", null, string.Empty);

            return(Json(new { Success = true }));
        }