public LocationSelectorInfo(LocationInformationList locations, string selectorId, string selectorName, bool required, int?selectedLocationId = null) { Locations = locations; SelectorId = selectorId; SelectorName = selectorName; Required = required; SelectedLocationId = selectedLocationId; }
// GET public IActionResult LocationSelection() { // TODO: There is a better way to do authentication, investigate and fix this in each controller if (HttpContext.Session.GetString("currentUsername") == null) { return(RedirectToAction("SignIn", "Home")); } LocationInformationList locationListModel = LocationService.getAvailableLocationsForUser("johndoe"); return(View(locationListModel)); }
public LocationInformationList getAvailableLocationsForUser(string username) { List <LocationInformation> locationsAvailableForUser = new List <LocationInformation>(); locationsAvailableForUser.Add(new LocationInformation(1, "DMV Merivale")); locationsAvailableForUser.Add(new LocationInformation(2, "DMV Ridgemont")); locationsAvailableForUser.Add(new LocationInformation(3, "DMV Walkley")); locationsAvailableForUser.Add(new LocationInformation(4, "DMV Westgate")); LocationInformationList locationInformationList = new LocationInformationList(); locationInformationList.LocationList = locationsAvailableForUser; return(locationInformationList); }
// GET public IActionResult LocationSelection() { // TODO: There is a better way to do authentication, investigate and fix this in each controller int?currentUsedId = HttpContext.Session.GetInt32("currentUserId"); if (currentUsedId == null) { return(RedirectToAction("SignIn", "Home")); } LocationInformationList locationListModel = LocationService.GetAvailableLocationsForUser(currentUsedId.Value); return(View(locationListModel)); }
public void getLocationByUserIDTest() { List <DatabaseLocation> dbAddressList = new List <DatabaseLocation>(); dbAddressList.Add(testLocation); dbAddressList.Add(testLocation2); Mock <IDatabaseQueryService> mockDBService = new Mock <IDatabaseQueryService>(MockBehavior.Strict); LocationService locationService = new LocationService(mockDBService.Object); mockDBService.Setup(x => x.GetLocationsForUser(1)).Returns(dbAddressList); LocationInformationList locationInformationList = locationService.GetAvailableLocationsForUser(1); Assert.That(locationInformationList.LocationList[0].LocationName, Is.EqualTo("DMV")); Assert.That(locationInformationList.LocationList[1].LocationName, Is.EqualTo("DMV2")); }