Exemplo n.º 1
0
        public SiteSettingTranslation CreateSiteSettingTranslation(long languageID, long siteSettingID, string title, string description, string keyword, string footerText)
        {
            DateTime date = DateTime.Now;

            SiteSettingTranslation siteSettingTranslation = new SiteSettingTranslation
            {
                Description = description,
                FooterText = footerText,
                Keyword = keyword,
                LanguageID = languageID,
                SiteSettingID = siteSettingID,
                Title = title,
                CreatedDate = date,
                UpdatedDate = date
            };

            context.SiteSettingTranslation.Add(siteSettingTranslation);

            SiteSetting siteSetting = this.GetSiteSetting();

            siteSetting.UpdatedDate = date;

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    context.SaveChanges();
                    scope.Complete();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            return siteSettingTranslation;
        }
Exemplo n.º 2
0
        public SiteSettingIndexModel LoadIndex(long? languageID)
        {
            SiteSettingBusiness siteSettingBusiness = new SiteSettingBusiness();
            LanguageBusiness languageBusiness = new LanguageBusiness();

            SiteSettingIndexModel siteSettingIndexModel = new SiteSettingIndexModel();

            SiteSetting siteSetting = siteSettingBusiness.GetSiteSetting();
            SiteSettingTranslation siteSettingTranslation = null;

            if (languageID.HasValue)
            {
                siteSettingTranslation = siteSetting.SiteSettingTranslation.FirstOrDefault(z => z.LanguageID == languageID);
            }
            else
            {
                siteSettingTranslation = siteSetting.SiteSettingTranslation.FirstOrDefault();
            }

            if (siteSettingTranslation == null)
                siteSettingTranslation = new SiteSettingTranslation();

            IEnumerable<Language> languageList = languageBusiness.LanguageList();

            siteSettingIndexModel.LanguageList = new SelectList(languageList, "ID", "Name", languageID);
            siteSettingIndexModel.LanguageID = siteSettingTranslation.LanguageID;
            siteSettingIndexModel.Title = siteSettingTranslation.Title;
            siteSettingIndexModel.Description = siteSettingTranslation.Description;
            siteSettingIndexModel.Keyword = siteSettingTranslation.Keyword;
            siteSettingIndexModel.FooterText = siteSettingTranslation.FooterText;
            siteSettingIndexModel.Email = siteSetting.Email;
            siteSettingIndexModel.EmailPassword = siteSetting.EmailPassword;
            siteSettingIndexModel.EmailPort = siteSetting.EmailPort;
            siteSettingIndexModel.SiteSettingID = siteSetting.ID;

            return siteSettingIndexModel;
        }