public List <Sections> getAllSections()
        {
            List <Sections> result = new List <Sections>();

            using (CrystalSiegeEntities content = new CrystalSiegeEntities())
            {
                result = content.Sections.OrderBy(s => s.Id).ToList();
                if (result.Count == 0)
                {
                    return(null);
                }
                foreach (Sections item in result)
                {
                    item.title = CoderUTF8.Decode(item.title);
                }
            }
            return(result);
        }
        /*
         * public int ID { get; set; }
         * public string Title { get; set; }
         * public string Content { get; set; }
         * public string Author { get; set; }
         * [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
         * public DateTime DatePublish { get; set; }
         * public Boolean IsPublish { get; set; }
         * public string ImageSrc { get; set; }
         * public int PaperclipType { get; set; }*/

        /* przekazuje listę swoich obiektów */
        public List <News> getAllNews(int pub)
        {
            List <News> result = new List <News>();

            using (CrystalSiegeEntities content = new CrystalSiegeEntities())
            {
                result = content.News.Where(q => q.publish >= pub).OrderByDescending(s => s.date).ToList();
                if (result.Count == 0)
                {
                    return(null);
                }
                foreach (News item in result)
                {
                    item.title       = CoderUTF8.Decode(item.title);
                    item.description = CoderUTF8.Decode(item.description);
                }
            }
            return(result);
        }
示例#3
0
        /*
         * public decimal Id { get; set; }
         * public Nullable<System.DateTime> date { get; set; }
         * public string page { get; set; }*/

        public static void SaveVisitToDB(string url)
        {
            using (CrystalSiegeEntities contents = new CrystalSiegeEntities())
            {
                try
                {
                    Visit vis = new Visit
                    {
                        date = DateTime.Now,
                        page = url
                    };
                    contents.Visit.Add(vis);
                    contents.SaveChanges();
                }
                catch (Exception ex)
                {
                }
            }
        }
示例#4
0
        public List <CarouselInfo> getAllSlides()
        {
            List <CarouselInfo> result = new List <CarouselInfo>();

            using (CrystalSiegeEntities content = new CrystalSiegeEntities())
            {
                result = content.CarouselInfo.OrderBy(s => s.Id).ToList();
                if (result.Count == 0)
                {
                    return(null);
                }
                foreach (CarouselInfo item in result)
                {
                    item.Title       = CoderUTF8.Decode(item.Title);
                    item.Description = CoderUTF8.Decode(item.Description);
                    item.Link        = CoderUTF8.Decode(item.Link);
                }
            }
            return(result);
        }
        public List <List <Subsections> > getAllSubsections()
        {
            List <Sections>            result1 = new List <Sections>();
            List <List <Subsections> > result2 = new List <List <Subsections> >();

            using (CrystalSiegeEntities content = new CrystalSiegeEntities())
            {
                result1 = content.Sections.OrderBy(s => s.Id).ToList();
                if (result1.Count == 0)
                {
                    return(null);
                }
                foreach (Sections item in result1)
                {
                    List <Subsections> tmp = content.Sections.Where(s => s.Id == item.Id).SingleOrDefault().Subsections.ToList();
                    foreach (Subsections item2 in tmp)
                    {
                        item2.title = CoderUTF8.Decode(item2.title);
                    }
                    result2.Add(tmp);
                }
            }
            return(result2);
        }