/// <summary> /// Updates the localized topic /// </summary> /// <param name="localizedTopic">Localized topic</param> public void UpdateLocalizedTopic(LocalizedTopic localizedTopic) { if (localizedTopic == null) { throw new ArgumentNullException("localizedTopic"); } localizedTopic.Title = CommonHelper.EnsureNotNull(localizedTopic.Title); localizedTopic.Title = CommonHelper.EnsureMaximumLength(localizedTopic.Title, 200); localizedTopic.Body = CommonHelper.EnsureNotNull(localizedTopic.Body); localizedTopic.MetaTitle = CommonHelper.EnsureNotNull(localizedTopic.MetaTitle); localizedTopic.MetaTitle = CommonHelper.EnsureMaximumLength(localizedTopic.MetaTitle, 400); localizedTopic.MetaKeywords = CommonHelper.EnsureNotNull(localizedTopic.MetaKeywords); localizedTopic.MetaKeywords = CommonHelper.EnsureMaximumLength(localizedTopic.MetaKeywords, 400); localizedTopic.MetaDescription = CommonHelper.EnsureNotNull(localizedTopic.MetaDescription); localizedTopic.MetaDescription = CommonHelper.EnsureMaximumLength(localizedTopic.MetaDescription, 4000); if (!_context.IsAttached(localizedTopic)) { _context.LocalizedTopics.Attach(localizedTopic); } _context.SaveChanges(); }
/// <summary> /// Gets a localized topic by name and language identifier /// </summary> /// <param name="Name">topic name</param> /// <param name="LanguageID">Language identifier</param> /// <returns>Localized topic</returns> public static LocalizedTopic GetLocalizedTopic(string Name, int LanguageID) { DBLocalizedTopic dbItem = DBProviderManager <DBTopicProvider> .Provider.GetLocalizedTopic(Name, LanguageID); LocalizedTopic localizedTopic = DBMapping(dbItem); return(localizedTopic); }
/// <summary> /// Gets a localized topic by identifier /// </summary> /// <param name="LocalizedTopicID">Localized topic identifier</param> /// <returns>Localized topic</returns> public static LocalizedTopic GetLocalizedTopicByID(int LocalizedTopicID) { if (LocalizedTopicID == 0) { return(null); } DBLocalizedTopic dbItem = DBProviderManager <DBTopicProvider> .Provider.GetLocalizedTopicByID(LocalizedTopicID); LocalizedTopic localizedTopic = DBMapping(dbItem); return(localizedTopic); }
/// <summary> /// Inserts a localized topic /// </summary> /// <param name="TopicID">The topic identifier</param> /// <param name="LanguageID">The language identifier</param> /// <param name="Title">The title</param> /// <param name="Body">The body</param> /// <param name="CreatedOn">The date and time of instance creation</param> /// <param name="UpdatedOn">The date and time of instance update</param> /// <param name="showOnHomePage">State of showing topic on the home page</param> /// <returns>Localized topic</returns> public static LocalizedTopic InsertLocalizedTopic(int TopicID, int LanguageID, string Title, string Body, DateTime CreatedOn, DateTime UpdatedOn, int showOnHomePage) { CreatedOn = DateTimeHelper.ConvertToUtcTime(CreatedOn); UpdatedOn = DateTimeHelper.ConvertToUtcTime(UpdatedOn); DBLocalizedTopic dbItem = DBProviderManager <DBTopicProvider> .Provider.InsertLocalizedTopic(TopicID, LanguageID, Title, Body, CreatedOn, UpdatedOn, showOnHomePage); LocalizedTopic localizedTopic = DBMapping(dbItem); return(localizedTopic); }
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; }
private static LocalizedTopicCollection DBMapping(DBLocalizedTopicCollection dbCollection) { if (dbCollection == null) { return(null); } LocalizedTopicCollection collection = new LocalizedTopicCollection(); foreach (DBLocalizedTopic dbItem in dbCollection) { LocalizedTopic item = DBMapping(dbItem); collection.Add(item); } return(collection); }
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); }
private static LocalizedTopic DBMapping(DBLocalizedTopic dbItem) { if (dbItem == null) { return(null); } var 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.MetaDescription = dbItem.MetaDescription; item.MetaKeywords = dbItem.MetaKeywords; item.MetaTitle = dbItem.MetaTitle; return(item); }
/// <summary> /// Inserts a localized topic /// </summary> /// <param name="localizedTopic">Localized topic</param> public void InsertLocalizedTopic(LocalizedTopic localizedTopic) { if (localizedTopic == null) { throw new ArgumentNullException("localizedTopic"); } localizedTopic.Title = CommonHelper.EnsureNotNull(localizedTopic.Title); localizedTopic.Title = CommonHelper.EnsureMaximumLength(localizedTopic.Title, 200); localizedTopic.Body = CommonHelper.EnsureNotNull(localizedTopic.Body); localizedTopic.MetaTitle = CommonHelper.EnsureNotNull(localizedTopic.MetaTitle); localizedTopic.MetaTitle = CommonHelper.EnsureMaximumLength(localizedTopic.MetaTitle, 400); localizedTopic.MetaKeywords = CommonHelper.EnsureNotNull(localizedTopic.MetaKeywords); localizedTopic.MetaKeywords = CommonHelper.EnsureMaximumLength(localizedTopic.MetaKeywords, 400); localizedTopic.MetaDescription = CommonHelper.EnsureNotNull(localizedTopic.MetaDescription); localizedTopic.MetaDescription = CommonHelper.EnsureMaximumLength(localizedTopic.MetaDescription, 4000); _context.LocalizedTopics.AddObject(localizedTopic); _context.SaveChanges(); }
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; }