Exemplo n.º 1
0
 private ActionResult DefaultEmailNewsletterView()
 {
     UserProfile profile = new UserProfile();
     EmailNewsletter model = new EmailNewsletter();
     if (base.User.Identity.IsAuthenticated)
     {
         profile = this.GetModel();
         if (profile != null)
         {
             model.IsLoggedIn = true;
             model.EmailAddress = profile.CustomerDetails.EmailAddress;
         }
     }
     string identifier = string.Format(this._settings.CraftListCategory, this.PublicationId);
     IList<Coats.Crafts.Models.Keyword> keywordsList = this._keywordrepository.GetKeywordsList(identifier);
     Location location = null;
     if (!model.IsLoggedIn)
     {
         try
         {
             location = new Location(base.HttpContext.Request.QueryString["fh_params"].Split(new char[] { '&' }).SingleOrDefault<string>(f => f.StartsWith("fh_location=")).Replace("fh_location=", ""));
         }
         catch (Exception)
         {
             location = null;
         }
     }
     foreach (Coats.Crafts.Models.Keyword keyword in keywordsList)
     {
         Func<SelectListItem, bool> predicate = null;
         SelectListItem sli = new SelectListItem {
             Text = keyword.Description,
             Value = keyword.Id,
             Selected = true
         };
         if (model.IsLoggedIn)
         {
             if (profile != null)
             {
                 if (predicate == null)
                 {
                     predicate = c => c.Value == sli.Value;
                 }
                 SelectListItem item = profile.CraftTypeList.SingleOrDefault<SelectListItem>(predicate);
                 sli.Selected = (item != null) && item.Selected;
             }
         }
         else if (location != null)
         {
             try
             {
                 List list2 = location.getCriteria("techniques");
                 if (list2.size() > 0)
                 {
                     sli.Selected = list2.ToString().Contains(string.Format("techniques{0}{1}", FacetedContentHelper.NestedLevelDelimiter, sli.Text.ToLower().Replace(" ", "_")));
                 }
             }
             catch (Exception)
             {
             }
         }
         model.Techniques.Add(sli);
         model.Techniques.Count<SelectListItem>(t => t.Selected);
     }
     return base.View("~/Views/Partials/EmailNewsletter.cshtml", model);
 }
Exemplo n.º 2
0
 public ActionResult Index(ComponentPresentation componentPresentation, UserProfile model)
 {
     this.Logger.DebugFormat("Called Update Profile >>>> ", new object[0]);
     try
     {
         ((dynamic) base.ViewBag).Title = componentPresentation.Component.Fields["title"].Value;
     }
     catch (Exception)
     {
     }
     string email = string.Empty;
     if (base.User.Identity.IsAuthenticated)
     {
         email = base.User.Identity.Name;
     }
     bool flag = this.IsEditModelValid(model);
     if (flag)
     {
         try
         {
             MembershipUser user = Membership.GetUser();
             if (user == null)
             {
                 flag = false;
                 this.Logger.DebugFormat("Update Profile mUser null", new object[0]);
             }
             if (model.AddressDetails.Postcode != null)
             {
                 this.FindPostcode(model);
             }
             if (model.RegistrationStatus == "postcode invalid")
             {
                 flag = false;
             }
             if (flag)
             {
                 this.Logger.DebugFormat("User profile start  >>>>", new object[0]);
                 CoatsUserProfile userProfile = CoatsUserProfile.GetProfile(user.Email);
                 if (userProfile != null)
                 {
                     string selectedKeywords = base.Request["CraftType"];
                     string str3 = base.Request["email-newsletter"];
                     string str4 = base.Request["visibile-profile"];
                     PublicasterServiceRequest request = new PublicasterServiceRequest();
                     string newsletter = "No";
                     if (str3.Trim() == WebConfiguration.Current.EmailNewsletterYes.Trim())
                     {
                         newsletter = "yes";
                     }
                     if (((selectedKeywords != null) || (str3 != null)) || (str4 != null))
                     {
                         List<TridionTcmUri> keywordsSelectListItems = GetKeywordsSelectListItems(selectedKeywords);
                         List<TridionTcmUri> second = GetKeywordsSelectListItems(str3);
                         List<TridionTcmUri> list3 = GetKeywordsSelectListItems(str4);
                         IEnumerable<TridionTcmUri> enumerable = keywordsSelectListItems.Union<TridionTcmUri>(second).Union<TridionTcmUri>(list3);
                         Dictionary<string, string> dictionary = new Dictionary<string, string>();
                         foreach (TridionTcmUri uri in enumerable)
                         {
                             dictionary.Add(uri.TcmId, "tcm");
                         }
                         userProfile.Keywords = dictionary;
                         model.Keywords = dictionary;
                     }
                     if (!string.IsNullOrEmpty(model.NewPassword))
                     {
                         if (model.NewPassword == model.VerifyNewPassword)
                         {
                             if (!string.IsNullOrEmpty(model.CurrentPassword))
                             {
                                 CoatsUserProfile profile = CoatsUserProfile.GetProfile(email);
                                 if (model.CurrentPassword == profile.PASSWORD)
                                 {
                                     model.CustomerDetails.Password = model.NewPassword;
                                 }
                                 else
                                 {
                                     flag = false;
                                     base.ModelState.AddModelError("CurrentPasswordIncorrect", Helper.GetResource("CurrentPasswordIncorrect"));
                                 }
                             }
                             else
                             {
                                 flag = false;
                             }
                         }
                         else
                         {
                             flag = false;
                             base.ModelState.AddModelError("NewPasswordsNotMatch", Helper.GetResource("NewPasswordsNotMatch"));
                         }
                     }
                     if (flag)
                     {
                         this.MapUserProfileForUpdate(model, userProfile);
                         userProfile.Save();
                         if ((str3 != null) && WebConfiguration.Current.CheckEmailNewsletterOption)
                         {
                             if (str3.Trim() == WebConfiguration.Current.EmailNewsletterYes.Trim())
                             {
                                 EmailUtility utility = new EmailUtility();
                                 string fromEmailAddress = ConfigurationManager.AppSettings["PasswordReminderEmailFrom"];
                                 string emailTemplate = ConfigurationManager.AppSettings["RegisterConfirmationEmailTemplate"];
                                 string registerThankYou = this._settings.RegisterThankYou;
                                 string str9 = HttpUtility.UrlEncode(General.Encrypt(userProfile.MAIL.Trim()));
                                 registerThankYou = registerThankYou + "?UserEmail=" + str9;
                                 model.CustomerDetails.SiteUrl = registerThankYou;
                                 model.CustomerDetails.DisplayName = userProfile.DISPLAYNAME;
                                 model.CustomerDetails.EmailAddress = userProfile.MAIL;
                                 string str10 = utility.SendEmail(model.CustomerDetails, emailTemplate, fromEmailAddress, userProfile.MAIL);
                                 this.Logger.DebugFormat("ProfileController : Register Confirmation Email > result {0}", new object[] { str10 });
                                 request.createJsonPublicasterRequest(userProfile.MAIL, userProfile.NAME, userProfile.SURNAME, selectedKeywords, userProfile.DISPLAYNAME, newsletter);
                             }
                             else
                             {
                                 request.UnSubscripePublicaster(userProfile.MAIL);
                             }
                         }
                         CoatsUserProfile profile3 = CoatsUserProfile.GetProfile(userProfile.MAIL);
                         CookieHelper.WriteFormsCookie(userProfile.MAIL, userProfile.DISPLAYNAME, userProfile.NAME, userProfile.SURNAME, userProfile.LONG, userProfile.LAT, "");
                         ((dynamic) base.ViewBag).profileStatus = "saved";
                         if (profile3 == null)
                         {
                             flag = false;
                             base.ModelState.AddModelError(string.Empty, "");
                             this.Logger.DebugFormat("Update Profile newUser null", new object[0]);
                         }
                     }
                 }
             }
         }
         catch (Exception exception)
         {
             this.Logger.DebugFormat("Update Profile exception {0} {1}", new object[] { exception.Message, exception.InnerException });
             flag = false;
         }
     }
     if (base.ModelState.ContainsKey("CustomerDetails.DisplayName"))
     {
         base.ModelState["CustomerDetails.DisplayName"].Errors.Clear();
     }
     if (base.ModelState.ContainsKey("CustomerDetails.EmailAddress"))
     {
         base.ModelState["CustomerDetails.EmailAddress"].Errors.Clear();
     }
     if (!flag)
     {
         UserProfile profile4 = this.GetModel();
         base.ModelState.AddModelError(string.Empty, "");
         var typeArray = (from x in base.ModelState
             where x.Value.Errors.Count > 0
             select new { 
                 Key = x.Key,
                 Errors = x.Value.Errors
             }).ToArray();
         foreach (var type in typeArray)
         {
             this.Logger.DebugFormat("Update Profile error {0}", new object[] { type });
         }
         this.GetModelData(profile4);
         base.Session["feedback"] = Helper.GetResource("ProfileError");
         ((dynamic) base.ViewBag).profileStatus = "error";
         return base.View(profile4);
     }
     UserProfile profile5 = this.GetModel();
     base.Session["feedback"] = Helper.GetResource("ProfileChangesSaved");
     return base.View(profile5);
 }
Exemplo n.º 3
0
 private void MapUserProfileForUpdate(UserProfile model, CoatsUserProfile userProfile)
 {
     this.Logger.DebugFormat("MapUserProfileForUpdate", new object[0]);
     try
     {
         userProfile.NAME = model.CustomerDetails.FirstName;
         userProfile.SURNAME = model.CustomerDetails.LastName;
         userProfile.TELEPHONE = model.CustomerDetails.TelephoneNumber;
         userProfile.ABOUT = model.CustomerDetails.About;
         userProfile.LONG = model.CustomerDetails.Long;
         userProfile.LAT = model.CustomerDetails.Lat;
         userProfile.Keywords = model.Keywords;
         userProfile.POSTCODE = model.AddressDetails.Postcode;
         userProfile.PASSWORD = model.CustomerDetails.Password;
     }
     catch (Exception exception)
     {
         this.Logger.DebugFormat("MapUserProfileForUpdate ex {0}", new object[] { exception.Message });
     }
 }
Exemplo n.º 4
0
 private void GetModelData(UserProfile userProfile)
 {
     userProfile.CraftTypeList = GetKeywordsSelectList(userProfile, this._keywordrepository.GetKeywordsList(this._craftlistidentifier));
     userProfile.EmailNewsletter = GetKeywordsSelectList(userProfile, this._keywordrepository.GetKeywordsList(this._emailnewsletteridentifier));
     userProfile.ProfileVisible = GetKeywordsSelectList(userProfile, this._keywordrepository.GetKeywordsList(this._profilevisibleidentifier));
 }
Exemplo n.º 5
0
 private static List<SelectListItem> GetKeywordsSelectList(UserProfile model, IEnumerable<Coats.Crafts.Models.Keyword> keywords)
 {
     List<SelectListItem> list = new List<SelectListItem>();
     List<int> list2 = new List<int>();
     TridionTcmUri tcmUri = new TridionTcmUri();
     foreach (KeyValuePair<string, string> pair in model.Keywords)
     {
         tcmUri = UtilityHelper.GetTcmUri(pair.Key);
         list2.Add(tcmUri.TcmItemId);
     }
     TridionTcmUri uri2 = new TridionTcmUri();
     foreach (Coats.Crafts.Models.Keyword keyword in keywords)
     {
         uri2 = UtilityHelper.GetTcmUri(keyword.Id);
         list.Add(list2.Contains(uri2.TcmItemId) ? new SelectListItem() : new SelectListItem());
     }
     return (from x in list
         orderby x.Text
         select x).ToList<SelectListItem>();
 }
Exemplo n.º 6
0
 private ViewResult FindPostcode(UserProfile model)
 {
     Dictionary<string, string> dictionary = new Dictionary<string, string>();
     if (!string.IsNullOrEmpty(model.AddressDetails.Postcode))
     {
         float num;
         float num2;
         string s = base.Request["lat"];
         string str2 = base.Request["long"];
         bool flag = float.TryParse(s, out num2);
         bool flag2 = float.TryParse(str2, out num);
         if (flag && flag2)
         {
             model.CustomerDetails.Lat = s;
             model.CustomerDetails.Long = str2;
         }
         else
         {
             dictionary = this.CheckPostcode(model.AddressDetails.Postcode);
             if (dictionary.Count > 0)
             {
                 model.CustomerDetails.Lat = dictionary["lat"];
                 model.CustomerDetails.Long = dictionary["long"];
             }
             else
             {
                 model.RegistrationStatus = "postcode invalid";
                 base.ModelState.AddModelError(string.Empty, Helper.GetResource("PostcodeError"));
             }
         }
     }
     return base.View(model);
 }
 private static void MapUserProfile(UserProfile model, CoatsUserProfile userProfile)
 {
     userProfile.POSTCODE = model.AddressDetails.Postcode;
     userProfile.MAIL = model.CustomerDetails.EmailAddress;
     userProfile.NAME = model.CustomerDetails.FirstName;
     userProfile.SURNAME = model.CustomerDetails.LastName;
     userProfile.TELEPHONE = model.CustomerDetails.TelephoneNumber;
     userProfile.PASSWORD = model.CustomerDetails.Password;
     userProfile.ADDRESSBOOKID = int.Parse(ConfigurationManager.AppSettings["AddressBookId"]);
     userProfile.DISPLAYNAME = model.CustomerDetails.DisplayName;
     userProfile.ABOUT = model.CustomerDetails.About;
     userProfile.LONG = model.CustomerDetails.Long;
     userProfile.LAT = model.CustomerDetails.Lat;
     userProfile.Keywords = model.Keywords;
 }
 private bool IsProfileValid(UserProfile model)
 {
     bool flag = true;
     if (model != null)
     {
         if (string.IsNullOrEmpty(model.CustomerDetails.EmailAddress))
         {
             flag = false;
             base.ModelState.AddModelError("EmailAddress", Helper.GetResource("EmailAddressEmpty"));
             this.errorList.Add("EmailAddress");
         }
         if (string.IsNullOrEmpty(model.CustomerDetails.Password))
         {
             flag = false;
             base.ModelState.AddModelError("Password", Helper.GetResource("PasswordEmpty"));
             this.errorList.Add("Password");
         }
         if (string.IsNullOrEmpty(model.CustomerDetails.VerifyPassword))
         {
             flag = false;
             base.ModelState.AddModelError("VerifyPassword", Helper.GetResource("VerifyPasswordEmpty"));
             this.errorList.Add("VerifyPassword");
         }
         if (model.CustomerDetails.Password != model.CustomerDetails.VerifyPassword)
         {
             flag = false;
             base.ModelState.AddModelError("VerifyPassword", Helper.GetResource("ComparePassword"));
             this.errorList.Add("PasswordMatch");
         }
         if (string.IsNullOrEmpty(model.CustomerDetails.FirstName))
         {
             flag = false;
             base.ModelState.AddModelError("FirstName", Helper.GetResource("FirstNameEmpty"));
             this.errorList.Add("FirstName");
         }
         if (string.IsNullOrEmpty(model.CustomerDetails.LastName))
         {
             flag = false;
             base.ModelState.AddModelError("LastName", Helper.GetResource("LastNameEmpty"));
             this.errorList.Add("LastName");
         }
         if (string.IsNullOrEmpty(model.CustomerDetails.DisplayName))
         {
             flag = false;
             base.ModelState.AddModelError("DisplayName", Helper.GetResource("DisplayNameEmpty"));
             this.errorList.Add("DisplayName");
         }
     }
     return flag;
 }