示例#1
0
        public ActionResult Index(FrontEndCmsPage page, string k)
        {
            FrontEndSubscriptionRegister frontEndSubscriptionRegister = new FrontEndSubscriptionRegister()
            {
                LangugeCode = page.LanguageCode
            };

            ViewBag.IsActivationPage = false;
            if (k.IsNotEmptyOrWhiteSpace())
            {
                ViewBag.IsActivationPage = true;
                Subscriptions subscriptions = new Subscriptions();
                int?          result        = subscriptions.ActivativateSubscription(k);
                switch (result)
                {
                case 0:
                    Subscription subscription = subscriptions.GetSubscriptionByActivationKey(k);

                    GlobalConfiguration globalConfiguration = new GlobalConfigurations().GetGlobalConfiguration();

                    CultureInfoHelper.ForceBackEndLanguage();

                    string subject = Resources.Strings_Subscription.EmailSubscriptionAddedSubject.Replace("{$Url}", globalConfiguration.DomainName.ToUrl());
                    string body    = Resources.Strings_Subscription.EmailSubscriptionAddedBody
                                     .Replace("{$Url}", globalConfiguration.DomainName.ToUrl())
                                     .Replace("{$subscriptionEmail}", subscription.Email)
                                     .Replace("{$ipAddress}", Request.UserHostAddress);

                    CultureInfoHelper.RestoreFrontEndLanguage();

                    EmailHelper email = new EmailHelper(globalConfiguration.NotificationEmail, globalConfiguration.NotificationEmail, subject, body);
                    email.Send();

                    ViewBag.ActivationResult = Resources.Strings_Subscription.ActivationKeySuccess;
                    break;

                case 2:
                    ViewBag.ActivationResult = Resources.Strings_Subscription.ActivationKeyInvalid;
                    break;

                case 3:
                    ViewBag.ActivationResult = Resources.Strings_Subscription.ActivationKeyAlreadyUsed;
                    break;

                default:
                    ViewBag.ActivationResult = Resources.Strings.UnexpectedError;
                    break;
                }
            }

            return(View(frontEndSubscriptionRegister));
        }
示例#2
0
        public ActionResult Index(FrontEndCmsPage page, FrontEndContact frontEndContact)
        {
            if (ModelState.IsValidOrRefresh())
            {
                if (frontEndContact.Notes.IsEmpty()) //Honey pot to avoid spammers
                {
                    GlobalConfiguration globalConfiguration = new GlobalConfigurations().GetGlobalConfiguration();

                    CultureInfoHelper.ForceBackEndLanguage();

                    string subject = Resources.Strings_Contact.EmailSubject.Replace("{$Url}", globalConfiguration.DomainName.ToUrl());
                    string body    = Resources.Strings_Contact.EmailBody
                                     .Replace("{$fullName}", frontEndContact.FullName)
                                     .Replace("{$companyName}", frontEndContact.CompanyName)
                                     .Replace("{$phoneNumber}", frontEndContact.PhoneNumber)
                                     .Replace("{$email}", frontEndContact.Email)
                                     .Replace("{$message}", frontEndContact.Message)
                                     .Replace("{$ipAddress}", Request.UserHostAddress)
                                     .Replace("{$Url}", globalConfiguration.DomainName.ToUrl());

                    CultureInfoHelper.RestoreFrontEndLanguage();

                    EmailHelper email = new EmailHelper(globalConfiguration.NotificationEmail, globalConfiguration.NotificationEmail, subject, body);
                    email.ReplyToList.Add(frontEndContact.Email);
                    if (email.Send())
                    {
                        ModelState.AddResult(ViewData, ModelStateResult.Success, Resources.Strings_Contact.Thanks);
                        ViewData.IsFormVisible(false);
                    }
                    else
                    {
                        ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.UnexpectedError);
                    }
                }
                else
                {
                    ModelState.AddResult(ViewData, ModelStateResult.Success, Resources.Strings_Contact.Thanks);
                    ViewData.IsFormVisible(false);
                }
            }

            return(View(frontEndContact));
        }
示例#3
0
        public ActionResult Index(FrontEndCmsPage page, FrontEndNews frontEndNews)
        {
            News news = new News();

            if (page.Parameter.IsNotEmptyOrWhiteSpace())
            {
                SingleNews singleNews = news.GetSingleNews(page.Parameter.Split('-').FirstOrDefault().ConvertTo <int?>(null, true), page.LanguageCode);

                if (singleNews.IsNotNull())
                {
                    NewsComments newsComments = new NewsComments();

                    frontEndNews.LanguageCode      = page.LanguageCode;
                    frontEndNews.NewsList          = null;
                    frontEndNews.FilterCategoryId  = null;
                    frontEndNews.FilterNewsDate    = null;
                    frontEndNews.NewsId            = singleNews.NewsId;
                    frontEndNews.NewsDate          = singleNews.NewsDate;
                    frontEndNews.UserName          = singleNews.UserName;
                    frontEndNews.CategoryId        = singleNews.CategoryId;
                    frontEndNews.CategoryName      = singleNews.CategoryName;
                    frontEndNews.MainImageFilePath = singleNews.MainImageFilePath;
                    frontEndNews.NewsTitle         = singleNews.NewsTitle;
                    frontEndNews.NewsContent       = singleNews.NewsContent;
                    frontEndNews.NewsCommentList   = (newsComments.IsNotNull() ? newsComments.GetNewsComments(singleNews.NewsId, true) : null);
                }
                else
                {
                    frontEndNews = null;
                }
            }

            if (ModelState.IsValidOrRefresh() && frontEndNews.IsNotNull())
            {
                NewsConfiguration newsConfiguration = new NewsConfigurations().GetNewsConfiguration();

                NewsComments newsComments = new NewsComments();
                int?         result       = newsComments.Add((int)frontEndNews.NewsId,
                                                             newsConfiguration.IsCommentAutoApproved,
                                                             frontEndNews.NewsComment,
                                                             DateTime.Now,
                                                             FrontEndSessions.CurrentSubscription.Email);
                switch (result)
                {
                case 0:
                    ModelState.AddResult(ViewData, ModelStateResult.Success, Resources.Strings_News.CommentAdded);
                    ViewData.IsFormVisible(false);

                    GlobalConfiguration globalConfiguration = new GlobalConfigurations().GetGlobalConfiguration();

                    CultureInfoHelper.ForceBackEndLanguage();

                    string subject = Resources.Strings_News.EmailSubject.Replace("{$Url}", globalConfiguration.DomainName.ToUrl());
                    string body    = Resources.Strings_News.EmailBody
                                     .Replace("{$Url}", globalConfiguration.DomainName.ToUrl())
                                     .Replace("{$subscriptionEmail}", FrontEndSessions.CurrentSubscription.Email)
                                     .Replace("{$comment}", frontEndNews.NewsComment)
                                     .Replace("{$ipAddress}", Request.UserHostAddress);

                    CultureInfoHelper.RestoreFrontEndLanguage();

                    EmailHelper email = new EmailHelper(globalConfiguration.NotificationEmail, globalConfiguration.NotificationEmail, subject, body);
                    email.Send();
                    break;

                default:
                    ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.UnexpectedError + " (Database)");
                    break;
                }
            }

            return(View(frontEndNews));
        }