public async Task GetAllNicknames() { var results = await Nickname.GetAllAsync(_azureSql); Assert.NotNull(results); Assert.True(results.Any()); }
public async Task <IActionResult> MapAsync(string journeyName, string teamName, string name) { var response = new Map(); if (!string.IsNullOrWhiteSpace(journeyName) && (journeyName.Length < 100)) { journeyName = journeyName.Trim(); var journeys = await Journey.GetByJourneyNameAsync(journeyName, _azureSQL); response.Journey = journeys.FirstOrDefault(); var entries = await Step.GetByJourneyAsync(response.Journey?.JourneyName, _azureSQL); foreach (var entry in entries) { response.StepsTaken += entry.Steps; } } if (!(string.IsNullOrWhiteSpace(teamName)) && (teamName.Length < 100)) { teamName = teamName.Trim(); var teams = await Team.GetByTeamNameAsync(teamName, _azureSQL); response.Team = teams.FirstOrDefault(); } else { var teams = await Team.GetAllAsync(_azureSQL); response.Teams = teams.OrderBy(x => x.TeamName); } if (!(string.IsNullOrWhiteSpace(name)) && (name.Length < 100)) { name = name.Trim(); var nicknames = await Nickname.GetByNicknameAsync(name, _azureSQL); response.Nickname = nicknames.FirstOrDefault(); } else { var nicknames = await Nickname.GetAllAsync(_azureSQL); response.Nicknames = nicknames.OrderBy(x => x.Name); } if (response?.Journey is null || string.IsNullOrWhiteSpace(response?.Journey?.JourneyName)) { return(Redirect("/")); } return(View("Map", response)); }
public async Task <IActionResult> IndexAsync(string name) { if (string.IsNullOrWhiteSpace(name)) { var results = await Nickname.GetAllAsync(_azureSQL); return(View("Nicknames", new NicknameSearchResult { Query = name, Nicknames = results })); } else { var results = await Nickname.GetByNicknameAsync(name, _azureSQL); if (!results.Any()) { results = await Nickname.SearchByNicknameAsync(name, _azureSQL); } if (results.Count() > 1) { return(View("Nicknames", new NicknameSearchResult { Query = name, Nicknames = results })); } else { return(View("Nicknames", new NicknameSearchResult { Query = name, Nicknames = results })); } } }