Ejemplo 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);
 }
 public ActionResult EmailNewsletterSignup(EmailNewsletter emailNewsLetter)
 {
     Registration model = new Registration();
     LoginForm form = new LoginForm();
     RegistrationForm form2 = new RegistrationForm();
     model.RegistrationForm = form2;
     model.LoginForm = form;
     this.GetModelData(model.RegistrationForm);
     model.RegistrationForm.CraftTypeList = emailNewsLetter.Techniques;
     SelectListItem item = model.RegistrationForm.EmailNewsletter.SingleOrDefault<SelectListItem>(e => e.Text == "Yes");
     if (item != null)
     {
         item.Selected = true;
     }
     SelectListItem item2 = model.RegistrationForm.EmailNewsletter.SingleOrDefault<SelectListItem>(e => e.Text == "No");
     if (item2 != null)
     {
         item2.Selected = false;
     }
     model.RegistrationForm.CustomerDetails.EmailAddress = emailNewsLetter.EmailAddress;
     return base.View("Index", model);
 }
Ejemplo n.º 3
0
 public ActionResult EmailNewsletterSettings(EmailNewsletter emailNewsLetter, string EmailNewsletterSubmit, string redirectUrl)
 {
     bool flag = base.Request.IsAjaxRequest();
     bool flag2 = false;
     bool flag3 = false;
     string str = string.Empty;
     string resource = Helper.GetResource("ProfileNotLoggedIn");
     this.Logger.Debug("POST request for EmailNewsletterSettings triggered");
     this.Logger.DebugFormat("emailNewsLetter {0} & EmailNewsletterSubmit {1}", new object[] { emailNewsLetter == null, EmailNewsletterSubmit });
     if (base.User.Identity.IsAuthenticated && !string.IsNullOrEmpty(EmailNewsletterSubmit))
     {
         Action<SelectListItem> action = null;
         CoatsUserProfile coatsUserProfile = CoatsUserProfile.GetProfile(base.HttpContext.User.Identity.Name);
         this.Logger.DebugFormat("coatsUserProfile? {0}", new object[] { coatsUserProfile == null });
         if (coatsUserProfile != null)
         {
             if (emailNewsLetter != null)
             {
                 if (action == null)
                 {
                     action = delegate (SelectListItem t) {
                         Func<KeyValuePair<string, string>, bool> predicate = null;
                         if (!t.Selected)
                         {
                             if (predicate == null)
                             {
                                 predicate = k => k.Key == t.Value;
                             }
                             foreach (KeyValuePair<string, string> pair in coatsUserProfile.Keywords.Where<KeyValuePair<string, string>>(predicate).ToList<KeyValuePair<string, string>>())
                             {
                                 this.Logger.DebugFormat("Removing {0} {1}", new object[] { pair.Key, pair.Value });
                                 coatsUserProfile.Keywords.Remove(pair.Key);
                             }
                         }
                         if (!(!t.Selected || coatsUserProfile.Keywords.ContainsKey(t.Value)))
                         {
                             this.Logger.DebugFormat("Adding {0}", new object[] { t.Value });
                             coatsUserProfile.Keywords.Add(t.Value, "tcm");
                         }
                     };
                 }
                 emailNewsLetter.Techniques.ForEach(action);
             }
             coatsUserProfile.Save();
         }
         flag2 = true;
         resource = Helper.GetResource("PreferencesUpdated");
         redirectUrl = !string.IsNullOrEmpty(redirectUrl) ? redirectUrl : this._settings.EmailNewsLetterConfirmation;
         this.Logger.DebugFormat("Redirecting to {0}", new object[] { redirectUrl });
         if (!flag)
         {
             return this.Redirect(redirectUrl);
         }
     }
     if (base.Request.IsAjaxRequest())
     {
         return base.Json(new { 
             success = flag2,
             allowRedirect = flag3,
             redirect = str,
             message = resource
         });
     }
     return this.DefaultEmailNewsletterView();
 }
 public ActionResult Index(IComponentPresentation componentPresentation, EmailNewsletter emailNewsletter, string ReturnUrl = "", string stepoverride = "register")
 {
     if (!base.User.Identity.IsAuthenticated)
     {
         stepoverride = "register";
     }
     ((dynamic) base.ViewBag).Stage = stepoverride;
     try
     {
         ((dynamic) base.ViewBag).Title = componentPresentation.Component.Fields["title"].Value;
     }
     catch (Exception)
     {
     }
     Registration model = new Registration {
         RegistrationForm = new RegistrationForm(),
         LoginForm = new LoginForm()
     };
     NameValueCollection @params = base.Request.Params;
     if (!string.IsNullOrEmpty(@params["action"]))
     {
         if (@params["action"] == "addtoshoppinglist")
         {
             ((dynamic) base.ViewBag).Title = Helper.GetResource("SignupShoppingList");
         }
         if (@params["action"] == "download")
         {
             ((dynamic) base.ViewBag).Title = Helper.GetResource("SignupDownload");
         }
     }
     if (!string.IsNullOrEmpty(ReturnUrl))
     {
         model.LoginForm.ReturnUrl = ReturnUrl + "?" + base.Request.QueryString.ToString().Replace("iframe=true", "");
         model.RegistrationForm.returnUrl = ReturnUrl + "?" + base.Request.QueryString.ToString().Replace("iframe=true", "");
     }
     else if (!string.IsNullOrWhiteSpace(base.Request.QueryString["source"]))
     {
         model.RegistrationForm.returnUrl = model.LoginForm.ReturnUrl = base.Request.QueryString["source"];
     }
     else
     {
         model.LoginForm.ReturnUrl = base.Url.Content(WebConfiguration.Current.MyProfile);
         model.RegistrationForm.returnUrl = base.Url.Content(WebConfiguration.Current.MyProfile);
     }
     this.GetModelData(model.RegistrationForm);
     if ((emailNewsletter.Techniques != null) && (emailNewsletter.Techniques.Count > 0))
     {
         model.RegistrationForm.CraftTypeList = emailNewsletter.Techniques;
     }
     if (!string.IsNullOrEmpty(emailNewsletter.EmailAddress))
     {
         model.RegistrationForm.CustomerDetails.EmailAddress = emailNewsletter.EmailAddress;
     }
     SelectListItem item = model.RegistrationForm.EmailNewsletter.SingleOrDefault<SelectListItem>(e => e.Text == "No");
     if (item != null)
     {
         item.Selected = true;
     }
     return base.View(model);
 }