예제 #1
0
        public async Task <BlogItem> GetBlogSettings()
        {
            var         blog = new BlogItem();
            CustomField title, desc, about, items, cover, logo, theme, culture, includefeatured, headerscript, footerscript;

            title           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogTitle).FirstOrDefault();
            desc            = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogDescription).FirstOrDefault();
            about           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogAbout).FirstOrDefault();
            items           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogItemsPerPage).FirstOrDefault();
            cover           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogCover).FirstOrDefault();
            logo            = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogLogo).FirstOrDefault();
            theme           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogTheme).FirstOrDefault();
            culture         = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.Culture).FirstOrDefault();
            includefeatured = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.IncludeFeatured).FirstOrDefault();
            headerscript    = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.HeaderScript).FirstOrDefault();
            footerscript    = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.FooterScript).FirstOrDefault();

            blog.Title           = title == null ? "Blog Title" : title.Content;
            blog.About           = about == null ? "Blog About" : about.Content;
            blog.Description     = desc == null ? "Short blog description" : desc.Content;
            blog.ItemsPerPage    = items == null ? 10 : int.Parse(items.Content);
            blog.Cover           = cover == null ? "data/Daniel/2020/7/nordlys.jpg" : cover.Content;
            blog.Logo            = logo == null ? "admin/img/logo-white.png" : logo.Content;
            blog.Theme           = theme == null ? "Standard" : theme.Content;
            blog.Culture         = culture == null ? "en-US" : culture.Content;
            blog.IncludeFeatured = includefeatured == null ? false : bool.Parse(includefeatured.Content);
            blog.HeaderScript    = headerscript == null ? "" : headerscript.Content;
            blog.FooterScript    = footerscript == null ? "" : footerscript.Content;
            blog.SocialFields    = await GetSocial();

            return(await Task.FromResult(blog));
        }
        public Task <BlogItem> GetBlogSettings()
        {
            var         blog = new BlogItem();
            CustomField title, desc, items, cover, logo, theme, culture, includefeatured;

            title           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogTitle).FirstOrDefault();
            desc            = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogDescription).FirstOrDefault();
            items           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogItemsPerPage).FirstOrDefault();
            cover           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogCover).FirstOrDefault();
            logo            = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogLogo).FirstOrDefault();
            theme           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogTheme).FirstOrDefault();
            culture         = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.Culture).FirstOrDefault();
            includefeatured = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.IncludeFeatured).FirstOrDefault();

            blog.Title           = title == null ? "Blog Title" : title.Content;
            blog.Description     = desc == null ? "Short blog description" : desc.Content;
            blog.ItemsPerPage    = items == null ? 10 : int.Parse(items.Content);
            blog.Cover           = cover == null ? "admin/img/cover.png" : cover.Content;
            blog.Logo            = logo == null ? "admin/img/logo-white.png" : logo.Content;
            blog.Theme           = theme == null ? "Standard" : theme.Content;
            blog.Culture         = culture == null ? "en-US" : culture.Content;
            blog.IncludeFeatured = includefeatured == null ? false : bool.Parse(includefeatured.Content);

            return(Task.FromResult(blog));
        }
        public async Task <BlogItem> GetBlogSettings()
        {
            var         blog = new BlogItem();
            CustomField title, desc, items, cover, logo, theme, culture, includefeatured, headerscript, footerscript;

            title           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogTitle).FirstOrDefault();
            desc            = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogDescription).FirstOrDefault();
            items           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogItemsPerPage).FirstOrDefault();
            cover           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogCover).FirstOrDefault();
            logo            = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogLogo).FirstOrDefault();
            theme           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogTheme).FirstOrDefault();
            culture         = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.Culture).FirstOrDefault();
            includefeatured = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.IncludeFeatured).FirstOrDefault();
            headerscript    = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.HeaderScript).FirstOrDefault();
            footerscript    = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.FooterScript).FirstOrDefault();

            blog.Title           = title == null ? "Something went wrong :/" : title.Content;
            blog.Description     = desc == null ? "We are working to resolve the issue" : desc.Content;
            blog.ItemsPerPage    = items == null ? 10 : int.Parse(items.Content);
            blog.Cover           = cover == null ? "admin/img/cover.png" : cover.Content;
            blog.Logo            = logo == null ? "admin/img/logo-white.png" : logo.Content;
            blog.Theme           = theme == null ? "cleanblog" : theme.Content;
            blog.Culture         = culture == null ? "en-US" : culture.Content;
            blog.IncludeFeatured = includefeatured == null ? false : bool.Parse(includefeatured.Content);
            blog.HeaderScript    = headerscript == null ? "" : headerscript.Content;
            blog.FooterScript    = footerscript == null ? "" : footerscript.Content;
            blog.SocialFields    = await GetSocial();

            return(await Task.FromResult(blog));
        }
예제 #4
0
        public async Task SaveBlogSettings(BlogItem blog)
        {
            var title           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogTitle).FirstOrDefault();
            var desc            = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogDescription).FirstOrDefault();
            var about           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogAbout).FirstOrDefault();
            var items           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogItemsPerPage).FirstOrDefault();
            var cover           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogCover).FirstOrDefault();
            var logo            = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogLogo).FirstOrDefault();
            var culture         = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.Culture).FirstOrDefault();
            var theme           = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogTheme).FirstOrDefault();
            var includefeatured = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.IncludeFeatured).FirstOrDefault();
            var headerscript    = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.HeaderScript).FirstOrDefault();
            var footerscript    = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.FooterScript).FirstOrDefault();

            if (title == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.BlogTitle, Content = blog.Title
                });
            }
            else
            {
                title.Content = blog.Title;
            }

            if (desc == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.BlogDescription, Content = blog.Description
                });
            }
            else
            {
                desc.Content = blog.Description;
            }

            if (about == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.BlogAbout, Content = blog.About
                });
            }
            else
            {
                about.Content = blog.About;
            }

            if (items == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.BlogItemsPerPage, Content = blog.ItemsPerPage.ToString()
                });
            }
            else
            {
                items.Content = blog.ItemsPerPage.ToString();
            }

            if (cover == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.BlogCover, Content = blog.Cover
                });
            }
            else
            {
                cover.Content = blog.Cover;
            }

            if (logo == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.BlogLogo, Content = blog.Logo
                });
            }
            else
            {
                logo.Content = blog.Logo;
            }

            if (culture == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.Culture, Content = blog.Culture
                });
            }
            else
            {
                culture.Content = blog.Culture;
            }

            if (theme == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.BlogTheme, Content = blog.Theme
                });
            }
            else
            {
                theme.Content = blog.Theme;
            }

            if (includefeatured == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.IncludeFeatured, Content = blog.IncludeFeatured.ToString()
                });
            }
            else
            {
                includefeatured.Content = blog.IncludeFeatured.ToString();
            }

            if (headerscript == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.HeaderScript, Content = blog.HeaderScript
                });
            }
            else
            {
                headerscript.Content = blog.HeaderScript;
            }

            if (footerscript == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.FooterScript, Content = blog.FooterScript
                });
            }
            else
            {
                footerscript.Content = blog.FooterScript;
            }

            await _db.SaveChangesAsync();
        }
예제 #5
0
        public async Task SaveBlogSettings(BlogItem blog)
        {
            var title   = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogTitle).FirstOrDefault();
            var desc    = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogDescription).FirstOrDefault();
            var items   = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogItemsPerPage).FirstOrDefault();
            var cover   = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogCover).FirstOrDefault();
            var logo    = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogLogo).FirstOrDefault();
            var culture = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.Culture).FirstOrDefault();
            var theme   = _db.CustomFields.Where(f => f.AuthorId == 0 && f.Name == Constants.BlogTheme).FirstOrDefault();

            if (title == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.BlogTitle, Content = blog.Title
                });
            }
            else
            {
                title.Content = blog.Title;
            }

            if (desc == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.BlogDescription, Content = blog.Description
                });
            }
            else
            {
                desc.Content = blog.Description;
            }

            if (items == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.BlogItemsPerPage, Content = blog.ItemsPerPage.ToString()
                });
            }
            else
            {
                items.Content = blog.ItemsPerPage.ToString();
            }

            if (cover == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.BlogCover, Content = blog.Cover
                });
            }
            else
            {
                cover.Content = blog.Cover;
            }

            if (logo == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.BlogLogo, Content = blog.Logo
                });
            }
            else
            {
                logo.Content = blog.Logo;
            }

            if (culture == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.Culture, Content = blog.Culture
                });
            }
            else
            {
                culture.Content = blog.Culture;
            }

            if (theme == null)
            {
                _db.CustomFields.Add(new CustomField {
                    AuthorId = 0, Name = Constants.BlogTheme, Content = blog.Theme
                });
            }
            else
            {
                theme.Content = blog.Theme;
            }

            await _db.SaveChangesAsync();
        }