public async Task CreateAndDeleteAJourney() { var journey = new Journey { JourneyName = "AddDeleteTest", GeometryFileName = "/route.geojson", Bio = $"This is a test Journey created on {DateTime.Now}", Active = true, Created = DateTime.Now, ImagePath = "/images/DSC06102small.jpg" }; var result = await journey.PostAsync(_azureSql); Assert.True(result); var getFromDb = await Journey.GetByJourneyNameAsync(journey.JourneyName, _azureSql); Assert.True(getFromDb.Any()); var created = getFromDb.FirstOrDefault(); var checkDelete = await created.DeleteAsync(_azureSql); Assert.True(checkDelete); }
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 GetJourneyByName() { var results = await Journey.GetAllAsync(_azureSql); Assert.True(results.Any()); var selected = results.FirstOrDefault(); var checkid = await Journey.GetByJourneyNameAsync(selected.JourneyName, _azureSql); var selectedChecked = checkid.FirstOrDefault(); Assert.Equal(selected.JourneyName, selectedChecked.JourneyName); }
public async Task <IActionResult> SearchJournys(string journeyName) { if (string.IsNullOrWhiteSpace(journeyName)) { var results = await Journey.GetAllAsync(_azureSQL); return(View("Journeys", new JourneysSearchResult { Query = journeyName, Journeys = results })); } else { var results = await Journey.GetByJourneyNameAsync(journeyName, _azureSQL); if (!results.Any()) { results = await Journey.SearchByJourneyNameAsync(journeyName, _azureSQL); } //else if (results.Count() == 1) //{ // return Redirect($"/{results.FirstOrDefault().JourneyName}"); //} if (results.Count() > 1) { return(View("Journeys", new JourneysSearchResult { Query = journeyName, Journeys = results })); } //else if (results.Count() == 1) //{ // return Redirect($"/{results.FirstOrDefault().JourneyName}"); //} else { return(View("Journeys", new JourneysSearchResult { Query = journeyName, Journeys = results })); } } }
public async Task <IActionResult> ViewJourney(string journeyName) { var journeys = await Journey.GetByJourneyNameAsync(journeyName, _azureSQL); var journey = journeys.FirstOrDefault(); var entries = await Step.GetByJourneyAsync(journey?.JourneyName, _azureSQL); var uniqueTeamNames = entries.Select(x => x.TeamName).Distinct(); var teams = new List <Team>(); foreach (var team in uniqueTeamNames) { var results = await Team.GetByTeamNameAsync(team, _azureSQL); if (!(results is null)) { teams.Add(results.FirstOrDefault()); } } var uniqueNames = entries.Select(x => x.Nickname).Distinct(); var nicknames = new List <Nickname>(); foreach (var name in uniqueNames) { var results = await Nickname.GetByNicknameAsync(name, _azureSQL); if (!(results is null)) { nicknames.Add(results.FirstOrDefault()); } } // Maybe look up all the entries that reference this team? return(View("Journey", new JourneyResult { Journey = journey, Teams = teams, Nicknames = nicknames, Steps = entries })); }
public async Task <IActionResult> ViewName(string name) { var nicknames = await Nickname.GetByNicknameAsync(name, _azureSQL); var nickname = nicknames.FirstOrDefault(); var entries = await Step.GetByExactNicknameAsync(nickname?.Name, _azureSQL); var uniqueJourneyNames = entries.Select(x => x.JourneyName).Distinct(); var journeys = new List <Journey>(); foreach (var journey in uniqueJourneyNames) { var results = await Journey.GetByJourneyNameAsync(journey, _azureSQL); if (!(results is null)) { journeys.Add(results.FirstOrDefault()); } } var uniqueTeamNames = entries.Select(x => x.TeamName).Distinct(); var teams = new List <Team>(); foreach (var team in uniqueTeamNames) { var results = await Team.GetByTeamNameAsync(team, _azureSQL); if (!(results is null)) { teams.Add(results.FirstOrDefault()); } } return(View("Nickname", new NicknameResult { Nickname = nickname, Journeys = journeys, Teams = teams, Steps = entries })); }