private IEnumerable <string> GetTags(string searchString) { IEnumerable <string> tags = _utilitiesManager.GetAllTags() .Where(n => n.Name.ToUpper().Contains(searchString.ToUpper())) .Select(a => a.Name); return(tags); }
public ActionResult Tags() { var allTags = _utilityManager.GetAllTags().Include(n => n.SessionTags).ToList(); var viewmodel = new AdminTagsViewModel() { Tags = allTags }; return(View(viewmodel)); }
public void AddTagsAlreadyExistingAndNotExisting_ShouldReturnExpected() { List <Tag> tagsToAdd = new List <Tag>() { new Tag() { Name = "lunch" }, // existing new Tag() { Name = "SQL" }, // existing new Tag() { Name = "sql" }, // existing new Tag() { Name = "newtag" }, new Tag() { Name = "UNIQUETag" }, new Tag() { Name = "uniquetag" }, // duplicate }; _utilityManager.AddNewTagsToDb(tagsToAdd); // Original count is 6 var expectedCount = 8; var resultCount = _utilityManager.GetAllTags().Count(); Assert.AreEqual(expectedCount, resultCount); Assert.AreEqual("uniquetag", _utilityManager.GetAllTags().SingleOrDefault(n => n.Name == "uniquetag").Name); Assert.AreNotEqual(1, _utilityManager.GetAllTags().Count(n => n.Name == "UNIQUETag")); }
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)); }