/// <summary> /// PopulateModel /// </summary> /// <param name="contentLanguage"></param> /// <param name="languageID"></param> public void Populate(Content_Language contentLanguage, Guid languageID) { try { this.Page_Language = contentLanguage; if (this.Page_Language == null) { this.Page_Language = new Content_Language(); } //Populate main contents & right section contents JavaScriptSerializer serializer = new JavaScriptSerializer(); if (!string.IsNullOrEmpty(this.Page_Language.Description)) { try { this.MainContents = serializer.Deserialize <List <PageContent> >(this.Page_Language.Description); } catch (Exception ex) { ErrorLog.WriteLog("FaqModel", "MainContentSerializer", ex, ""); } } if (!string.IsNullOrEmpty(this.Page_Language.RightSection)) { try { this.RightSectionContents = serializer.Deserialize <List <PageContent> >(this.Page_Language.RightSection); } catch (Exception ex) { ErrorLog.WriteLog("FaqModel", "RightContentSerializer", ex, ""); } } if (this.MainContents == null || this.MainContents.Count == 0) { this.MainContents = new List <PageContent>(); this.MainContents.Add(new PageContent { Title = "", HTML = "" }); } if (this.RightSectionContents == null || this.RightSectionContents.Count == 0) { this.RightSectionContents = new List <PageContent>(); this.RightSectionContents.Add(new PageContent { Title = "", HTML = "" }); } } catch (Exception ex) { ErrorLog.WriteLog("FaqModel", "Populate", ex, ""); } }
/// <summary> /// Get Current Page /// </summary> /// <returns></returns> private static Content_Language GetCurrentPage() { var cacheProvider = CacheFactory.Get(); string[] currentURLSegments = HttpContext.Current.Request.RawUrl.Split('/'); string url = "/" + currentURLSegments[currentURLSegments.Length - 1].ToLower(); Content_Language pageLanguage = new Content_Language(); try { if (!cacheProvider.Exists(CacheKeys.CACHE_STATIC_PAGES)) { var pages = PageService.GetPages(); if (pages != null && pages.Count > 0) { cacheProvider.Add <List <Content> >(pages, CacheKeys.CACHE_STATIC_PAGES, 60 * 72); } var page = pages.Where(p => p.URL.ToLower() == url).FirstOrDefault(); if (page != null) { pageLanguage = page.Content_Languages.Where(pl => pl.LanguageID == TSMContext.CurrentSiteLanguageID).FirstOrDefault(); } if (pageLanguage == null) { pageLanguage = new Content_Language(); } } else { var pages = cacheProvider.Get <List <Content> >(CacheKeys.CACHE_STATIC_PAGES); var page = pages.Where(p => p.URL.ToLower() == url).FirstOrDefault(); if (page != null) { pageLanguage = page.Content_Languages.Where(pl => pl.LanguageID == TSMContext.CurrentSiteLanguageID).FirstOrDefault(); } if (pageLanguage == null) { pageLanguage = new Content_Language(); } } } catch (Exception ex) { ErrorLog.WriteLog("TSMContext", "GetCurrentPage", ex, ""); } return(pageLanguage); }
/// <summary> /// Populate Model /// </summary> /// <param name="id"></param> public void Populate(Content_Language contentLanguage, Guid languageID) { try { this.Page_Language = contentLanguage; if (this.Page_Language == null) { this.Page_Language = new Content_Language(); } } catch (Exception ex) { ErrorLog.WriteLog("PageDetailModel", "Populate", ex, ""); } }
/// <summary> /// Populate News /// </summary> /// <param name="id"></param> /// <returns></returns> public void GetNews(Guid id) { Content content = new Content(); Content_Language contentlang = new Content_Language(); try { content = ContentService.GetContent(id); contentlang = content.Content_Languages.Where(cl => cl.LanguageID == TSM.Model.TSMContext.CurrentSiteLanguageID).FirstOrDefault(); this.ImagePath = content.Image; this.LanguageID = TSM.Model.TSMContext.CurrentSiteLanguageID; this.SubTitle = contentlang.SubTitle; this.Summary = contentlang.Summary; this.Description = contentlang.Description; this.Title = contentlang.Title; this.HrefLink = content.HrefLink; //this.RecordId = content.RecordID; //this.RegionID = content.RegionID; //this.CountryID = content.CountryID; //this.LanguageID = content.Content_Languages[0].LanguageID; //this.SubTitle = content.Content_Languages[0].SubTitle; //this.Summary = content.Content_Languages[0].Summary; //this.Description = content.Content_Languages[0].Description; //this.Title = content.Content_Languages[0].Title; if (content.ContentDate != null) { this.ContentDate = (DateTime)content.ContentDate; } this.NewsContent = content; this.ID = id; //return user; } catch (Exception ex) { ErrorLog.WriteLog("ManageNewsModel", "GetNews", ex, ""); } // return content; }
/// <summary> /// Save /// </summary> /// <returns></returns> public bool Save() { bool isSuccess = false; try { var content = PageService.GetPage(this.ID); content.ID = this.ID; content.Type = this.Type; content.IsPublic = true; content.URL = this.URL; content.Image = string.Empty; content.IsActive = true; content.LastModifiedBy = TSMContext.CurrentUser.ID; content.LastModifiedDate = DateTime.UtcNow; //Add Language Option var contentLanguage = new Content_Language(); contentLanguage.ID = this.ID; contentLanguage.LanguageID = this.LanguageID; contentLanguage.Title = string.Empty; if (!string.IsNullOrEmpty(this.Title)) { contentLanguage.Title = this.Title.Trim(); } contentLanguage.SubTitle = " "; if (!string.IsNullOrEmpty(this.SubTitle)) { contentLanguage.SubTitle = this.SubTitle.Trim(); } contentLanguage.Summary = string.Empty; if (!string.IsNullOrEmpty(this.Summary)) { contentLanguage.Summary = this.Summary.Trim(); } foreach (var pageContent in this.MainContents) { if (string.IsNullOrEmpty(pageContent.Title)) { pageContent.Title = string.Empty; } if (string.IsNullOrEmpty(pageContent.HTML)) { pageContent.HTML = string.Empty; } } foreach (var pageContent in this.RightSectionContents) { if (string.IsNullOrEmpty(pageContent.Title)) { pageContent.Title = string.Empty; } if (string.IsNullOrEmpty(pageContent.HTML)) { pageContent.HTML = string.Empty; } } JavaScriptSerializer serializer = new JavaScriptSerializer(); contentLanguage.Description = serializer.Serialize(this.MainContents); contentLanguage.RightSection = serializer.Serialize(this.RightSectionContents); contentLanguage.PageTitle = string.Empty; if (!string.IsNullOrEmpty(this.BrowserTitle)) { contentLanguage.PageTitle = this.BrowserTitle.Trim(); } contentLanguage.PageKeywords = string.Empty; if (!string.IsNullOrEmpty(this.MetaKeywords)) { contentLanguage.PageKeywords = this.MetaKeywords.Trim(); } contentLanguage.PageMetadata = string.Empty; if (!string.IsNullOrEmpty(this.MetaDescription)) { contentLanguage.PageMetadata = this.MetaDescription.Trim(); } content.Content_Languages = new List <Content_Language>(); content.Content_Languages.Add(contentLanguage); PageService.Save(content, this.LanguageID); isSuccess = true; } catch (Exception ex) { ErrorLog.WriteLog("ManagePageModel", "Save", ex, ""); } return(isSuccess); }
/// <summary> /// PopulateModel /// </summary> /// <param name="contentLanguage"></param> /// <param name="languageID"></param> public void Populate(Content_Language contentLanguage, Guid languageID) { this.CaptchaSiteKey = AppSettingsUtility.GetString(AppSettingsKeys.CaptchaSiteKey); this.Contacts = new List <SelectListItem> { new SelectListItem { Text = "Technical", Value = "Technical" }, new SelectListItem { Text = "General enquiry", Value = "General enquiry" }, new SelectListItem { Text = "More information", Value = "More information" }, new SelectListItem { Text = "Other", Value = "Other" }, }; this.Salutations = new List <SelectListItem> { new SelectListItem { Text = "Mr.", Value = "Mr." }, new SelectListItem { Text = "Mrs.", Value = "Mrs." }, }; var countries = CountryService.GetCountries(languageID); Countries = new List <KeyValue>(); foreach (var country in countries) { Countries.Add(new KeyValue { Key = country.ID.ToString(), Value = country.Name }); } try { this.Page_Language = contentLanguage; if (this.Page_Language == null) { this.Page_Language = new Content_Language(); } //Populate main contents & right section contents JavaScriptSerializer serializer = new JavaScriptSerializer(); if (!string.IsNullOrEmpty(this.Page_Language.Description)) { try { this.MainContents = serializer.Deserialize <List <PageContent> >(this.Page_Language.Description); } catch (Exception ex) { ErrorLog.WriteLog("ContactUsModel", "MainContentSerializer", ex, ""); } } if (!string.IsNullOrEmpty(this.Page_Language.RightSection)) { try { this.RightSectionContents = serializer.Deserialize <List <PageContent> >(this.Page_Language.RightSection); } catch (Exception ex) { ErrorLog.WriteLog("ContactUsModel", "RightContentSerializer", ex, ""); } } if (this.MainContents == null || this.MainContents.Count == 0) { this.MainContents = new List <PageContent>(); this.MainContents.Add(new PageContent { Title = "", HTML = "" }); } if (this.RightSectionContents == null || this.RightSectionContents.Count == 0) { this.RightSectionContents = new List <PageContent>(); this.RightSectionContents.Add(new PageContent { Title = "", HTML = "" }); } } catch (Exception ex) { ErrorLog.WriteLog("ContactUsModel", "Populate", ex, ""); } }