public IActionResult Index(string search, int pageNumber) { List <Newsletter> newsletters = new List <Newsletter>(); if (!String.IsNullOrEmpty(search)) { newsletters = _newsletterRepository.Search(search).ToList(); pageNumber = 1; } else { newsletters = _newsletterRepository.GetAll().ToList(); } int pageSize = 10; pageNumber = (pageNumber > 0) ? pageNumber : 1; return(View(PaginatorExtension <Newsletter> .CreateAsync(newsletters, pageNumber, pageSize))); }
public NewsletterQueryResponse GetNewsletteEmails(NewsletterQueryRequest request) { var response = new NewsletterQueryResponse(); try { var newsletters = _newsletterRepository.GetAll(request.PageIndex, request.PageSize); response.NewsletterEmails = Mapper.Map <PagingQueryResponse <Newsletter>, PagingQueryResponse <NewsletterDto> >(newsletters); } catch (Exception exception) { _logger.Log(exception); response.Failed = true; } return(response); }
public async Task <IActionResult> Index( string sortOrder, string currentFilter, string searchString, int?page) { ViewData["CurrentSort"] = sortOrder; ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date"; ViewData["SubjectSortParm"] = sortOrder == "Subject" ? "sub_desc" : "Subject"; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewData["CurrentFilter"] = searchString; var contacts = _newsletterRepository.GetAll().Where(c => string.IsNullOrEmpty(searchString) || c.Subject.Contains(searchString) || c.NewsletterIntroText.Contains(searchString)); switch (sortOrder) { case "Date": contacts = contacts.OrderBy(c => c.SentAt); break; case "Subject": contacts = contacts.OrderBy(c => c.Subject); break; case "sub_desc": contacts = contacts.OrderByDescending(c => c.Subject); break; default: contacts = contacts.OrderByDescending(c => c.SentAt); break; } return(View(await PaginatedList <Newsletter> .Create(contacts, page ?? 1, 5))); }
// GET: Newsletters public async Task <IActionResult> Index() { return(View(await _newsletterRepository.GetAll())); }
public IList <NewsletterResult> GetAllNewsletter() { IList <NewsletterDto> newsletters = _newsletterRepository.GetAll(); return(newsletters.Select(newsletter => NewsletterParse(newsletter)).ToList()); }
public IEnumerable <Newsletter> Get() { return(_newsletterRepository.GetAll()); }