コード例 #1
0
        public ActionResult Index(string searchString)
        {
            var allParticipants = _personManager.GetAllParticipants()
                                  .Include(n => n.SessionParticipants);

            if (!string.IsNullOrEmpty(searchString))
            {
                allParticipants = allParticipants.Where(s => s.FirstName.ToLower().Contains(searchString.ToLower()) ||
                                                        s.LastName.ToLower().Contains(searchString.ToLower()));
            }

            var result = new IndexParticipantViewModel()
            {
                Participants = new List <ParticipantWithCountOfSessions>()
            };

            foreach (var participant in allParticipants)
            {
                result.Participants.Add(new ParticipantWithCountOfSessions()
                {
                    ParticipantId   = participant.Id,
                    FullName        = participant.FullName,
                    Email           = participant.Email,
                    CountOfSessions = participant.SessionParticipants.Count
                });
            }

            return(View(result));
        }
コード例 #2
0
        public ActionResult Index(string searchString, bool includeDeleted = false)
        {
            var allParticipants = _personManager.GetAllParticipantsIncludingDeleted()
                                  .Include(n => n.SessionParticipants);

            if (!string.IsNullOrEmpty(searchString))
            {
                allParticipants = allParticipants.Where(s => s.FirstName.ToLower().Contains(searchString.ToLower()) ||
                                                        s.LastName.ToLower().Contains(searchString.ToLower()));
            }
            // "Deleted" participants is by default hidden.
            if (!includeDeleted)
            {
                allParticipants = allParticipants.Except(allParticipants.Where(n => n.IsDeleted));
            }

            var result = new IndexParticipantViewModel()
            {
                Participants   = new List <ParticipantWithCountOfSessions>(),
                IncludeDeleted = includeDeleted
            };

            foreach (var participant in allParticipants)
            {
                result.Participants.Add(new ParticipantWithCountOfSessions()
                {
                    ParticipantId   = participant.Id,
                    FullName        = participant.FullName,
                    Email           = participant.Email,
                    CountOfSessions = participant.SessionParticipants.Count,
                    IsHrPerson      = participant.IsHrPerson,
                    IsActiv         = participant.IsActive,
                    IsDeleted       = participant.IsDeleted
                });
            }

            return(View(result));
        }