public ViewResult FilterSessionsForTag(string taglist, string id) { int tag; var totalParticipantCount = 0; var totalSessionCount = 0; var tagDisplay = "-- Välj etikett --"; var sessionsForTag = new List <Session>(); if (id != null && taglist == null) { taglist = id; } if (int.TryParse(taglist, out tag)) { var selectedTag = tag; sessionsForTag = _sessionManager.GetAllSessionsForTag(selectedTag) .Include(n => n.Activity) .Include(n => n.SessionParticipants) .ToList(); totalSessionCount = sessionsForTag.Count(); tagDisplay = _utilityManager.GetTag(selectedTag).Name; foreach (var session in sessionsForTag) { totalParticipantCount += _personManager.GetAllParticipantsForSession(session.Id).Count(); } } var allTags = _utilityManager.GetAllTags().OrderBy(n => n.Name).ToList(); var viewModel = new SessionTagsViewModel { tagName = tagDisplay, Tags = new SelectList(allTags, "Id", "Name"), Sessions = sessionsForTag, TotalParticipants = totalParticipantCount, TotalSessions = totalSessionCount, }; return(View(viewModel)); }