public ActionResult Index(int id, int pages = 1) { PageListView viewModel = new PageListView { Advertises = repository.Advertises .Where(p => p.Position >= 10 && p.Position <= 25 && p.PageTypeId == id), //Khobors = repositoryKhobor.Khobors // .Where(p => p.PageTypeId == id) // //.Skip((pages - 1) * PageSize) // .OrderByDescending(p => p.KhoborID) // .Take(PageSize) Khobors = (from k in repositoryKhobor.Khobors where k.PageTypeId == id orderby k.KhoborID descending select new Khobor { KhoborID = k.KhoborID, Title = k.Title, ImageDataTh = k.ImageDataTh, Introduction = k.Introduction }).Take(PageSize) , PageTypes = repositoryPageType.PageTypes .Where(p => p.PageTypeId == id).FirstOrDefault() //PagingInfo = new PagingInfo //{ // CurrentPage = pages, // ItemsPerPage = PageSize, // TotalItems = id == 0 ? // repositoryKhobor.Khobors.Count() : // repositoryKhobor.Khobors.Where(e => e.PageTypeId == id).Count() //} }; if (viewModel != null) { return View(viewModel); } else return View(); }
public ActionResult Zila(int id = 2, int pages = 1) { PageListView viewModel = new PageListView { Advertises = repository.Advertises .Where(p => p.Position >= 10 && p.Position <= 25 && p.PageTypeId == id), Khobors = (from k in repositoryKhobor.Khobors where k.PageTypeId == id orderby k.KhoborID descending select new Khobor { KhoborID = k.KhoborID, Title = k.Title, ImageDataTh = k.ImageDataTh, Introduction = k.Introduction.Substring(0, 80) }).Take(PageSize) , PageTypes = repositoryPageType.PageTypes .Where(p => p.PageTypeId == id).FirstOrDefault(), bdZilas = (from k in repositorybdzila.bdZilas where k.bdDivisionID == id orderby k.bdZilaID descending select new bdZila { bdZilaID = k.bdZilaID, bdZilaName = k.bdZilaName, bdDivisionID = k.bdDivisionID }) }; if (viewModel != null) { return View(viewModel); } else return View(); }
public ActionResult Search(string SearchString) { if (SearchString != null && SearchString != "") { PageListView viewModel = new PageListView { Advertises = repository.Advertises .Where(p => p.Position >= 10 && p.Position <= 25 && p.PageTypeId == 1), Khobors = (from k in repositoryKhobor.Khobors where k.Title.Contains(SearchString) orderby k.KhoborID descending select new Khobor { KhoborID = k.KhoborID, Title = k.Title, ImageDataTh = k.ImageDataTh, Introduction = k.Introduction }) }; if (viewModel != null) { return View(viewModel); } else return View(); } else { return View(); } }