예제 #1
0
        private static Topic DBMapping(DBTopic dbItem)
        {
            if (dbItem == null)
                return null;

            Topic item = new Topic();
            item.TopicID = dbItem.TopicID;
            item.Name = dbItem.Name;
            item.MetaDescription = dbItem.MetaDescription;
            item.MetaKeywords = dbItem.MetaKeywords;
            item.MetaTitle = dbItem.MetaTitle;

            return item;
        }
예제 #2
0
        public Topic SaveInfo()
        {
            //system info
            Topic topic = this.TopicService.GetTopicById(this.TopicId);
            if (topic != null)
            {
                topic.Name = txtSystemName.Text;
                topic.IsPasswordProtected = cbIsPasswordProtected.Checked;
                topic.Password = txtPassword.Text.Trim();
                topic.IncludeInSitemap = cbIncludeInSitemap.Checked;

                this.TopicService.UpdateTopic(topic);
            }
            else
            {
                topic = new Topic()
                {
                    Name = txtSystemName.Text,
                    IsPasswordProtected = cbIsPasswordProtected.Checked,
                    Password = txtPassword.Text.Trim(),
                    IncludeInSitemap = cbIncludeInSitemap.Checked
                };

                this.TopicService.InsertTopic(topic);
            }

            //localizable info
            DateTime nowDT = DateTime.UtcNow;
            foreach (RepeaterItem item in rptrLanguageDivs.Items)
            {
                if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                {
                    var txtTitle = (TextBox)item.FindControl("txtTitle");
                    var txtBody = (FCKeditor)item.FindControl("txtBody");
                    var lblLanguageId = (Label)item.FindControl("lblLanguageId");

                    int languageId = int.Parse(lblLanguageId.Text);
                    string title = txtTitle.Text;
                    string body = txtBody.Value;

                    var content = this.TopicService.GetLocalizedTopic(topic.Name, languageId);
                    if (content == null)
                    {
                        content = new LocalizedTopic()
                        {
                            TopicId = topic.TopicId,
                            LanguageId = languageId,
                            Title = title,
                            Body = body,
                            CreatedOn = nowDT,
                            UpdatedOn = nowDT
                        };

                        this.TopicService.InsertLocalizedTopic(content);
                    }
                    else
                    {
                        content.LanguageId = languageId;
                        content.Title = title;
                        content.Body = body;
                        content.UpdatedOn = nowDT;

                        this.TopicService.UpdateLocalizedTopic(content);
                    }
                }
            }
            foreach (RepeaterItem item in rptrLanguageDivs_SEO.Items)
            {
                if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                {
                    var txtMetaKeywords = (TextBox)item.FindControl("txtMetaKeywords");
                    var txtMetaDescription = (TextBox)item.FindControl("txtMetaDescription");
                    var txtMetaTitle = (TextBox)item.FindControl("txtMetaTitle");
                    var lblLanguageId = (Label)item.FindControl("lblLanguageId");

                    int languageId = int.Parse(lblLanguageId.Text);
                    string metaKeywords = txtMetaKeywords.Text;
                    string metaDescription = txtMetaDescription.Text;
                    string metaTitle = txtMetaTitle.Text;

                    var content = this.TopicService.GetLocalizedTopic(topic.Name, languageId);
                    if (content == null)
                    {
                        //localized topic should be already created on the previous step
                    }
                    else
                    {
                        content.UpdatedOn = nowDT;
                        content.MetaKeywords = metaKeywords;
                        content.MetaDescription = metaDescription;
                        content.MetaTitle = metaTitle;

                        this.TopicService.UpdateLocalizedTopic(content);
                    }
                }
            }

            return topic;
        }