public ActionResult ListMemberAdmin(string search, int?page)
        {
            if (page == null)
            {
                page = 1;
            }
            int pagenumber = (page ?? 1);
            int pagesize   = 200;

            if (search == null)
            {
                search = "";
            }
            search = new RemoveUnicodeModel().UnicodeNameModel(search.Trim());
            var datamember = db.UngViens.ToList();
            var listsearch = new List <UngVien>();

            if (search != "")
            {
                foreach (var item in datamember)
                {
                    string hovaten = new RemoveUnicodeModel().UnicodeNameModel(item.Hovatendem + " " + item.Ten);
                    string emaildn = new RemoveUnicodeModel().UnicodeNameModel(item.EmailDN);
                    string emaillh = new RemoveUnicodeModel().UnicodeNameModel(item.EmailLH);
                    string phone   = new RemoveUnicodeModel().UnicodeNameModel(item.Dienthoai1);
                    if (item.MAUV.ToString() == search || hovaten.Contains(search) || emaildn.Contains(search) || emaillh.Contains(search) || phone.Contains(search))
                    {
                        listsearch.Add(item);
                    }
                }
            }
            else
            {
                listsearch = datamember.Where(x => x.Tinhtrang != -1).ToList();
            }
            return(View(listsearch.OrderByDescending(x => x.MAUV).ToPagedList(pagenumber, pagesize)));
        }
Beispiel #2
0
        //public ActionResult ListNews(int? page)
        //{
        //    var listnew = db.News.ToList();
        //    var listsearch = new List<News>();
        //    string search = Request.QueryString["search"];
        //    string status = Request.QueryString["status"];
        //    if (!string.IsNullOrEmpty(status))
        //    {
        //        if (status == "1")
        //            listnew.Where(x => x.active == true && x.trash != true).ToList();
        //        else if (status == "-1")
        //            listnew.Where(x => x.active == false && x.trash != true).ToList();
        //        else if (status == "2")
        //            listnew.Where(x => x.showonhomepage == true && x.trash != true).ToList();
        //        else if (status == "-2")
        //            listnew.Where(x => x.showonhomepage == false && x.trash != true).ToList();
        //        else if (status == "3")
        //            listnew.Where(x => x.Featured == true && x.trash != true).ToList();
        //        else
        //            listnew.Where(x => x.Featured == false && x.trash != true).ToList();
        //    }
        //    if (!string.IsNullOrEmpty(search))
        //    {
        //        search = new RemoveUnicodeModel().UnicodeNameModel(search.Trim());
        //        foreach (var item in listnew)
        //        {
        //            string title = new RemoveUnicodeModel().UnicodeNameModel(item.titlenews);
        //            string author = new RemoveUnicodeModel().UnicodeNameModel(item.namepost);
        //            string datecreate = new RemoveUnicodeModel().UnicodeNameModel(item.datepost.Value.ToString("dd/MM/yyyy"));
        //            string category = new RemoveUnicodeModel().UnicodeNameModel(item.categorynew.categoryName);
        //            if (item.trash != true && item.newsid.ToString() == search || author.Contains(search) || title.Contains(search) || datecreate.Contains(search) || category.Contains(search))
        //            {
        //                listsearch.Add(item);
        //            }
        //        }
        //    }
        //    int pagesize = 100;
        //    int pagenumber = (page ?? 1);
        //    return View(listsearch.Where(x => x.trash != true).OrderByDescending(x => x.newsid).ToPagedList(pagenumber, pagesize));
        //}

        public ActionResult ListNews(string search, string status, int?page)
        {
            if (page == null)
            {
                page = 1;
            }
            int pagenumber = (page ?? 1);
            int pagesize   = 100;

            if (search == null)
            {
                search = "";
            }
            search = new RemoveUnicodeModel().UnicodeNameModel(search.Trim());
            List <News> datanews   = db.News.Where(x => x.trash != true).ToList();
            var         listsearch = new List <News>();

            if (status != null)
            {
                if (status == "1")
                {
                    datanews = datanews.Where(x => x.active == true).ToList();
                }
                else if (status == "-1")
                {
                    datanews = datanews.Where(x => x.active != true).ToList();
                }
                else if (status == "2")
                {
                    datanews = datanews.Where(x => x.showonhomepage == true).ToList();
                }
                else if (status == "-2")
                {
                    datanews = datanews.Where(x => x.showonhomepage != true).ToList();
                }
                else if (status == "3")
                {
                    datanews = datanews.Where(x => x.Featured == true).ToList();
                }
                else if (status == "-3")
                {
                    datanews = datanews.Where(x => x.Featured != true).ToList();
                }
            }
            if (search != "")
            {
                foreach (var item in datanews)
                {
                    string title      = new RemoveUnicodeModel().UnicodeNameModel(item.titlenews);
                    string author     = new RemoveUnicodeModel().UnicodeNameModel(item.namepost);
                    string datecreate = new RemoveUnicodeModel().UnicodeNameModel(item.datepost.Value.ToString("dd/MM/yyyy"));
                    string category   = new RemoveUnicodeModel().UnicodeNameModel(db.categorynews.Where(x => x.categoryId == item.categoryId).Select(x => x.categoryName).FirstOrDefault());
                    if (item.trash != true && item.newsid.ToString() == search || author.Contains(search) || title.Contains(search) || datecreate.Contains(search) || category.Contains(search))
                    {
                        listsearch.Add(item);
                    }
                }
            }
            else
            {
                listsearch = datanews;
            }
            return(View(listsearch.OrderByDescending(x => x.newsid).ToPagedList(pagenumber, pagesize)));
        }