コード例 #1
0
        public Forum SaveInfo()
        {
            Forum forum = this.ForumService.GetForumById(this.ForumId);
            DateTime nowDT = DateTime.UtcNow;

            if (forum != null)
            {
                forum.ForumGroupId = int.Parse(this.ddlForumGroup.SelectedItem.Value);
                forum.Name = txtName.Text;
                forum.Description = txtDescription.Text;
                forum.DisplayOrder = txtDisplayOrder.Value;
                forum.UpdatedOn = nowDT;

                this.ForumService.UpdateForum(forum);
            }
            else
            {
                forum = new Forum()
                {
                    ForumGroupId = int.Parse(this.ddlForumGroup.SelectedItem.Value),
                    Name = txtName.Text,
                    Description = txtDescription.Text,
                    DisplayOrder = txtDisplayOrder.Value,
                    CreatedOn = nowDT,
                    UpdatedOn = nowDT
                };

                this.ForumService.InsertForum(forum);
            }

            return forum;
        }
コード例 #2
0
ファイル: SEOHelper.cs プロジェクト: robbytarigan/ToyHouse
 /// <summary>
 /// Gets forum URL
 /// </summary>
 /// <param name="forum">Forum</param>
 /// <returns>Forum URL</returns>
 public static string GetForumUrl(Forum forum)
 {
     if(forum == null)
     {
         throw new ArgumentNullException("Forum");
     }
     string seName = GetSEName(forum.Name);
     string url2 = SEOHelper.EnableUrlRewriting ? IoC.Resolve<ISettingManager>().GetSettingValue("SEO.Forum.UrlRewriteFormat") : "{0}Boards/Forum.aspx?ForumId={1}";
     string url = string.Format(url2, CommonHelper.GetStoreLocation(), forum.ForumId, seName);
     return url.ToLowerInvariant();
 }
コード例 #3
0
        /// <summary>
        /// Replaces a message template tokens
        /// </summary>
        /// <param name="customer">Customer instance</param>
        /// <param name="forumPost">Forum post</param>
        /// <param name="forumTopic">Forum topic</param>
        /// <param name="forum">Forum</param>
        /// <param name="template">Template</param>
        /// <returns>New template</returns>
        private string ReplaceMessageTemplateTokens(Customer customer,
            ForumPost forumPost, ForumTopic forumTopic, Forum forum, string template)
        {
            var tokens = new NameValueCollection();
            tokens.Add("Store.Name", IoC.Resolve<ISettingManager>().StoreName);
            tokens.Add("Store.URL", IoC.Resolve<ISettingManager>().StoreUrl);
            tokens.Add("Store.Email", this.DefaultEmailAccount.Email);

            tokens.Add("Customer.Email", HttpUtility.HtmlEncode(customer.Email));
            tokens.Add("Customer.Username", HttpUtility.HtmlEncode(customer.Username));
            tokens.Add("Customer.FullName", HttpUtility.HtmlEncode(customer.FullName));
            tokens.Add("Customer.VatNumber", HttpUtility.HtmlEncode(customer.VatNumber));
            tokens.Add("Customer.VatNumberStatus", HttpUtility.HtmlEncode(customer.VatNumberStatus.ToString()));

            if (forumPost != null)
            {
                tokens.Add("Forums.PostAuthor", HttpUtility.HtmlEncode(forumPost.User.FormatUserName()));
                tokens.Add("Forums.PostBody", forumPost.FormatPostText());
            }
            if (forumTopic != null)
            {
                tokens.Add("Forums.TopicURL", SEOHelper.GetForumTopicUrl(forumTopic));
                tokens.Add("Forums.TopicName", HttpUtility.HtmlEncode(forumTopic.Subject));
            }
            if (forum != null)
            {
                tokens.Add("Forums.ForumURL", SEOHelper.GetForumUrl(forum));
                tokens.Add("Forums.ForumName", HttpUtility.HtmlEncode(forum.Name));
            }
            foreach (string token in tokens.Keys)
            {
                template = Replace(template, String.Format(@"%{0}%", token), tokens[token]);
            }

            return template;
        }
コード例 #4
0
        /// <summary>
        /// Sends a forum subscription message to a customer
        /// </summary>
        /// <param name="customer">Customer instance</param>
        /// <param name="forumTopic">Forum Topic</param>
        /// <param name="forum">Forum</param>
        /// <param name="languageId">Message language identifier</param>
        /// <returns>Queued email identifier</returns>
        public int SendNewForumTopicMessage(Customer customer, 
            ForumTopic forumTopic, Forum forum, int languageId)
        {
            if (customer == null)
                throw new ArgumentNullException("customer");

            string templateName = "Forums.NewForumTopic";
            var localizedMessageTemplate = this.GetLocalizedMessageTemplate(templateName, languageId);
            if(localizedMessageTemplate == null || !localizedMessageTemplate.IsActive)
                return 0;

            var emailAccount = localizedMessageTemplate.EmailAccount;

            string subject = ReplaceMessageTemplateTokens(customer, null, forumTopic, forum, localizedMessageTemplate.Subject);
            string body = ReplaceMessageTemplateTokens(customer, null, forumTopic, forum, localizedMessageTemplate.Body);
            string bcc = localizedMessageTemplate.BccEmailAddresses;
            var from = new MailAddress(emailAccount.Email, emailAccount.DisplayName);
            var to = new MailAddress(customer.Email, customer.FullName);
            var queuedEmail = InsertQueuedEmail(5, from, to, string.Empty, bcc, subject, body,
                DateTime.UtcNow, 0, null, emailAccount.EmailAccountId);
            return queuedEmail.QueuedEmailId;
        }
コード例 #5
0
ファイル: SEOHelper.cs プロジェクト: juliakolesen/voobrazi.by
        /// <summary>
        /// Gets forum URL
        /// </summary>
        /// <param name="forum">Forum</param>
        /// <returns>Forum URL</returns>
        public static string GetForumURL(Forum forum)
        {
            if (forum == null)
                throw new ArgumentNullException("forum");

            string url = string.Format("{0}Boards/Forum.aspx?ForumID={1}", CommonHelper.GetStoreLocation(), forum.ForumID);
            return url;
        }
コード例 #6
0
        private static Forum DBMapping(DBForum dbItem)
        {
            if (dbItem == null)
                return null;

            Forum item = new Forum();
            item.ForumID = dbItem.ForumID;
            item.ForumGroupID = dbItem.ForumGroupID;
            item.Name = dbItem.Name;
            item.Description = dbItem.Description;
            item.NumTopics = dbItem.NumTopics;
            item.NumPosts = dbItem.NumPosts;
            item.LastTopicID = dbItem.LastTopicID;
            item.LastPostID = dbItem.LastPostID;
            item.LastPostUserID = dbItem.LastPostUserID;
            item.LastPostTime = dbItem.LastPostTime;
            item.DisplayOrder = dbItem.DisplayOrder;
            item.CreatedOn = dbItem.CreatedOn;
            item.UpdatedOn = dbItem.UpdatedOn;

            return item;
        }
コード例 #7
0
        /// <summary>
        /// Check whether user is allowed to create new topics
        /// </summary>
        /// <param name="customer">Customer</param>
        /// <param name="forum">Forum</param>
        /// <returns>True if allowed, otherwise false</returns>
        public static bool IsUserAllowedToCreateTopic(Customer customer, Forum forum)
        {
            if (forum == null)
                return false;

            if (customer == null)
                return false;

            if (customer.IsGuest)
                return false;

            if (customer.IsForumModerator)
                return true;

            return true;
        }
コード例 #8
0
ファイル: ForumService.cs プロジェクト: robbytarigan/ToyHouse
        /// <summary>
        /// Updates the forum
        /// </summary>
        /// <param name="forum">Forum</param>
        public void UpdateForum(Forum forum)
        {
            if (forum == null)
                throw new ArgumentNullException("forum");

            forum.Name = CommonHelper.EnsureNotNull(forum.Name);
            forum.Name = CommonHelper.EnsureMaximumLength(forum.Name, 200);
            forum.Description = CommonHelper.EnsureNotNull(forum.Description);

            if (!_context.IsAttached(forum))
                _context.Forums.Attach(forum);
            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(FORUMGROUP_PATTERN_KEY);
                _cacheManager.RemoveByPattern(FORUM_PATTERN_KEY);
            }
        }