Example #1
0
        public void SaveSectionContent(SectionContent sectionItem)
        {
            SectionContent item;
            var insert = false;

            using (var repo = new CodeSlingers2012Entities())
            {
                item = (from r in repo.SectionContents
                        where r.Id == sectionItem.Id
                        select r).FirstOrDefault();

                if (item == null)
                {
                    item = new SectionContent();
                    insert = true;
                }

                item.ImageUrl = sectionItem.ImageUrl;
                item.Section = sectionItem.Section;
                item.SectionId = sectionItem.SectionId;
                item.SortOrder = sectionItem.SortOrder;
                item.SubSection = sectionItem.SubSection;
                item.Title = sectionItem.Title;
                item.ContentText = sectionItem.ContentText;
                item.ContentUrl = sectionItem.ContentUrl;
                item.ContentUrlText = sectionItem.ContentUrlText;

                if (insert)
                {
                    repo.SectionContents.Add(item);
                }

                repo.SaveChanges();
            }
        }
Example #2
0
        public SectionContent GetSectionContent(SectionNames section, int sectionId)
        {
            var item = new SectionContent();

            using (var repo = new CodeSlingers2012Entities())
            {
                item = (from r in repo.SectionContents
                        where r.Section == (int)section && r.SectionId == sectionId
                        select r).FirstOrDefault();
            }
            return item;
        }
Example #3
0
        public SectionContent GetSectionContentById(int Id)
        {
            var item = new SectionContent();

            using (var repo = new CodeSlingers2012Entities())
            {
                item = (from r in repo.SectionContents
                        where r.Id == Id
                        select r).FirstOrDefault();
            }
            return item;
        }
Example #4
0
        public List<SectionContent> GetAllSectionContent()
        {
            var items = new List<SectionContent>();

            using (var repo = new CodeSlingers2012Entities())
            {
                items = (from r in repo.SectionContents
                         orderby r.Section, r.SortOrder
                         select r).ToList();
            }
            return items;
        }
Example #5
0
        public List<SectionContent> GetSectionContentItems(SectionNames section)
        {
            var items = new List<SectionContent>();

            using (var repo = new CodeSlingers2012Entities())
            {
                items = (from r in repo.SectionContents
                         where r.Section == (int)section
                         orderby r.SortOrder
                         select r).ToList();
            }
            return items;
        }