Exemple #1
0
        public List <Posted> Search(string name)
        {
            List <Posted> ls   = new List <Posted>();
            var           list = db.Posts.Where(x => x.title.Contains(name) || name == null).ToList();

            foreach (var item in list)
            {
                var posted = new Posted()
                {
                    Content = item.content,
                    id      = item.id,
                    Title   = item.title
                };
                ls.Add(posted);
            }
            return(ls);
        }
Exemple #2
0
        public List <Posted> GetPosts()
        {
            List <Posted> ls   = new List <Posted>();
            var           list = db.Posts.ToList();

            foreach (var item in list)
            {
                var posted = new Posted()
                {
                    Content = item.content,
                    id      = item.id,
                    Title   = item.title
                };
                ls.Add(posted);
            }
            return(ls);
        }