예제 #1
0
        // GET: StaffNames
        public ViewResult Index()
        {
            //get a list of all the popular staff
            // List<StaffNames> PopularStaff = new List<StaffNames>();

            IEnumerable <StaffNames> AllStaff = _context.StaffNames.Distinct()
                                                .OrderBy(i => i.Department)
                                                .ThenBy(i => i.Name)
                                                .ToList();

            //where the count is over 0 and take the top 5
            //foreach (var staff in AllStaff.
            //    OrderByDescending(s => s.VisitorCount > 0)
            //    .Take(5))
            //{
            //    if (staff.VisitorCount > 0)
            //    {
            //        PopularStaff.Add(staff);

            //    }
            //}

            // ViewData["TopStaffList"] = PopularStaff.ToList();
            ViewData["TopStaffList"] = _dataBaseCalls.Top5StaffVisitors();

            return(View(AllStaff));
        }
예제 #2
0
        private List <SelectListItem> ListOfStaff(List <SelectListItem> Top5Staff)
        {
            Top5Staff.AddRange(_dataBaseCalls.Top5StaffVisitors()
                               .Select(n => new SelectListItem
            {
                Value = n.Id.ToString(),
                Text  = n.Name + " " + n.Department
            }).ToList());

            Top5Staff.AddRange(_context.StaffNames
                               .Select(n => new SelectListItem
            {
                Value = n.Id.ToString(),
                Text  = n.Name + " " + n.Department
            }).ToList());

            return(Top5Staff);
        }