Beispiel #1
0
        // GET: Hobbies
        public async Task <IActionResult> Index(string searchString, SortStateReport sortOrder = SortStateReport.NameAsc)
        {
            var applicationDbContext = _context.Hobbies.Include(h => h.ApplicationUsers);

            var hob = from jo in _context.Hobbies
                      select jo;

            if (!String.IsNullOrEmpty(searchString))
            {
                hob = hob.Where(s => s.HobbyName.Contains(searchString));
            }

            ViewData["NameSort"] = sortOrder == SortStateReport.NameAsc ? SortStateReport.NameDesc : SortStateReport.NameAsc;
            ViewData["DateSort"] = sortOrder == SortStateReport.DateAsc ? SortStateReport.DateDesc : SortStateReport.DateAsc;

            switch (sortOrder)
            {
            case SortStateReport.NameDesc:
                hob = hob.OrderByDescending(s => s.HobbyName);
                break;

            default:
                hob = hob.OrderBy(s => s.HobbyName);
                break;
            }

            return(View(await hob.ToListAsync()));
        }
Beispiel #2
0
        // GET: Motivations
        public async Task <IActionResult> Index(string searchString, SortStateReport sortOrder = SortStateReport.NameAsc)
        {
            var applicationDbContext = _context.Motivations.Include(m => m.ApplicationUsers);

            var mot = from jo in _context.Motivations
                      select jo;

            if (!String.IsNullOrEmpty(searchString))
            {
                mot = mot.Where(s => s.MotivationText.Contains(searchString));
            }

            ViewData["NameSort"] = sortOrder == SortStateReport.NameAsc ? SortStateReport.NameDesc : SortStateReport.NameAsc;
            ViewData["DateSort"] = sortOrder == SortStateReport.DateAsc ? SortStateReport.DateDesc : SortStateReport.DateAsc;

            switch (sortOrder)
            {
            case SortStateReport.NameDesc:
                mot = mot.OrderByDescending(s => s.MotivationText);
                break;

            case SortStateReport.DateAsc:
                mot = mot.OrderBy(s => s.MotivationText);
                break;

            case SortStateReport.DateDesc:
                mot = mot.OrderByDescending(s => s.MotivationText);
                break;

            default:
                mot = mot.OrderBy(s => s.MotivationText);
                break;
            }

            return(View(await mot.ToListAsync()));
        }
Beispiel #3
0
        // GET: Reports
        public async Task <IActionResult> Index(string searchString, SortStateReport sortOrder = SortStateReport.NameAsc)
        {
            var applicationDbContext = _context.Reports.Include(l => l.ApplicationUser);

            var rep = from r in _context.Reports
                      select r;

            if (!String.IsNullOrEmpty(searchString))
            {
                rep = rep.Where(s => s.Title.Contains(searchString));
            }

            ViewData["NameSort"] = sortOrder == SortStateReport.NameAsc ? SortStateReport.NameDesc : SortStateReport.NameAsc;
            ViewData["DateSort"] = sortOrder == SortStateReport.DateAsc ? SortStateReport.DateDesc : SortStateReport.DateAsc;

            switch (sortOrder)
            {
            case SortStateReport.NameDesc:
                rep = rep.OrderByDescending(s => s.Content);
                break;

            case SortStateReport.DateAsc:
                rep = rep.OrderBy(s => s.Day);
                break;

            case SortStateReport.DateDesc:
                rep = rep.OrderByDescending(s => s.Day);
                break;

            default:
                rep = rep.OrderBy(s => s.Content);
                break;
            }

            return(View(await rep.ToListAsync()));
        }