public FileResult DisplayParkingLotsOnMap() { List <Lot> allLots = iLotRepo.ListAllLots(); List <MapMarker> mapMarkers = new List <MapMarker>(); foreach (Lot eachLot in allLots) { MapMarker eachMapMarker = new MapMarker(); List <Location> locations = new List <Location>(); Location eachLocation = new Location(eachLot.LotAddress); locations.Add(eachLocation); eachMapMarker.Locations = locations; eachMapMarker.Label = eachLot.LotNumber; //can only be 0-9 or A-Z eachMapMarker.Color = GoogleApi.Entities.Maps.StaticMaps.Request.Enums.MapColor.Blue; mapMarkers.Add(eachMapMarker); } StaticMapsRequest staticMapsRequest = new StaticMapsRequest(); if (!String.IsNullOrEmpty(HttpContext.Session.GetString("WVUEmployeeID"))) { string WVUEmployeeID = HttpContext.Session.GetString("WVUEmployeeID"); WVUEmployee employee = iApplicationUserRepo.FindWvuEmployee(WVUEmployeeID); string origin = employee.Department.DepartmentAddress; MapMarker eachMapMarker = new MapMarker(); List <Location> locations = new List <Location>(); Location employeeLocation = new Location(origin); locations.Add(employeeLocation); eachMapMarker.Locations = locations; eachMapMarker.Label = "E"; //can only be 0-9 or A-Z eachMapMarker.Color = GoogleApi.Entities.Maps.StaticMaps.Request.Enums.MapColor.Purple; mapMarkers.Add(eachMapMarker); staticMapsRequest.Center = employeeLocation; } staticMapsRequest.Key = "AIzaSyBRT65jDLR_mhb4yzGbMBMaIZALz57028A"; staticMapsRequest.Markers = mapMarkers; staticMapsRequest.Type = GoogleApi.Entities.Maps.StaticMaps.Request.Enums.MapType.Roadmap; StaticMapsResponse response = GoogleApi.GoogleMaps.StaticMaps.Query(staticMapsRequest); var file = response.Buffer; return(File(file, "image/jpeg")); }
public IActionResult ShowAllLots() //tests logic of controller methods { //Two options: //1.Get data from database //2.Inject mock data from test class/method List <Lot> lotList = iLotRepo.ListAllLots(); //database.Lots.Include(l => l.LotStatuses).ThenInclude(ls => ls.LotType).ToList<Lot>(); //Send the data to the UI layer return(View(lotList)); }