コード例 #1
0
        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)));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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)));
        }
コード例 #4
0
 // GET: Newsletters
 public async Task <IActionResult> Index()
 {
     return(View(await _newsletterRepository.GetAll()));
 }
コード例 #5
0
        public IList <NewsletterResult> GetAllNewsletter()
        {
            IList <NewsletterDto> newsletters = _newsletterRepository.GetAll();

            return(newsletters.Select(newsletter => NewsletterParse(newsletter)).ToList());
        }
コード例 #6
0
 public IEnumerable <Newsletter> Get()
 {
     return(_newsletterRepository.GetAll());
 }