private static LocalizedTopic DBMapping(DBLocalizedTopic dbItem) { if (dbItem == null) return null; LocalizedTopic item = new LocalizedTopic(); item.TopicLocalizedID = dbItem.TopicLocalizedID; item.TopicID = dbItem.TopicID; item.LanguageID = dbItem.LanguageID; item.Title = dbItem.Title; item.Body = dbItem.Body; item.CreatedOn = dbItem.CreatedOn; item.UpdatedOn = dbItem.UpdatedOn; item.ShowOnHomePage = dbItem.ShowOnHomePage; return item; }
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; }