public ParentController(IRepositoryWrapper repo, MailKitService mailKitService, GoogleMapsService mapsService) { _repo = repo; var test = _repo.Parent.FindAll().ToList(); _email = mailKitService; _maps = mapsService; }
public void QuandoSolicitaADistanciaEntreNiteroiERioDeJaneiro_DeveRetornarComSucesso() { var googleMapsService = new GoogleMapsService(apiKey: cApiKey); var distanceMatrix = googleMapsService.GetDistanceMatrix( origins: "Niterói - RJ", destinations: "Rio de Janeiro - RJ" ); Assert.IsNotNull(distanceMatrix); Assert.IsNotNull(distanceMatrix.Distance); Assert.IsNotNull(distanceMatrix.Duration); Console.WriteLine(distanceMatrix.Distance.Text); Console.WriteLine(distanceMatrix.Distance.Value); Console.WriteLine(distanceMatrix.Duration.Text); Console.WriteLine(distanceMatrix.Duration.Value); }
public static void Main(string[] args) { System.Console.Write("Enter With Your API Key Here: "); var apiKey = System.Console.ReadLine(); var googleMapsService = new GoogleMapsService(apiKey); var distanceMatrix = googleMapsService.GetDistanceMatrix( origins: "Niterói - RJ", destinations: "Rio de Janeiro - RJ" ); System.Console.WriteLine(); System.Console.WriteLine(distanceMatrix.Origin_Addresses.FirstOrDefault()); System.Console.WriteLine(distanceMatrix.Destination_Addresses.FirstOrDefault()); System.Console.WriteLine(distanceMatrix.Distance.Text); System.Console.WriteLine(distanceMatrix.Distance.Value + " metros"); System.Console.WriteLine(distanceMatrix.Duration.Text); System.Console.WriteLine(distanceMatrix.Duration.Value + " segundos"); System.Console.Write("Pressione Enter pra finalizar ..."); System.Console.ReadLine(); }
private async Task <ObservableCollection <Location> > SuggestLocations(string word) { //Looks at the back end google servers for the location word = suggestion; var url = GoogleMapsService.GenerateUrl(nameOfPlace: word); SuggestionLocations = new ObservableCollection <Location>(); using (HttpClient client = new HttpClient()) { var response = await client.GetAsync(url); var json = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <Location>(json); SuggestionLocations = result.formattedAddress as ObservableCollection <Location>; } return(SuggestionLocations); }
private async void SaveBtn(object sender, EventArgs e) { ToolbarItem i = sender as ToolbarItem; i.Clicked -= SaveBtn; var hud = DependencyService.Get <IHUDProvider>(); hud.DisplayProgress("Saving Data"); await Task.Delay(500); if (!string.IsNullOrWhiteSpace(nameEntry.Text) && categoryPicker.SelectedIndex >= 0 && !string.IsNullOrWhiteSpace(addressEntry.Text) && !string.IsNullOrWhiteSpace(landmarkEntry.Text) && ViewModel.Items.Count > 0) { if (CrossConnectivity.Current.IsConnected) { FireSharpClient FsClient = FireSharpClient.Instance; if (IsLocation == false) { GoogleMapsService googleMapsService = GoogleMapsService.Instance; var l = await googleMapsService.GetLocationFromAddress(addressEntry.Text); if (l != null) { CurrentLatitude = l.lat; CurrentLongitude = l.lng; } else { var addressInvalid = "Address is not available on Google Maps"; addressInvalid.ToToast(ToastNotificationType.Error); } } Store s = new Store { Name = nameEntry.Text, Category = AppConstants.CATEGORIES[categoryPicker.SelectedIndex], Address = addressEntry.Text, IsLocation = this.IsLocation, Latitude = this.CurrentLatitude, Longitude = this.CurrentLongitude, Landmark = landmarkEntry.Text }; List <string> tempList = new List <string>(); foreach (var item in ViewModel.Items) { tempList.Add(item.Name); } s.Tags = tempList.ToArray(); var pushKey = await FsClient.Push("stores", s); hud.Dismiss(); await Navigation.PopAsync(); var msg = "Your data has been saved."; msg.ToToast(ToastNotificationType.Error); } else { hud.Dismiss(); var msg = "Make sure you're connected to Internet."; msg.ToToast(ToastNotificationType.Error); } } else { hud.Dismiss(); var msg = "Please Fill All the Fields"; msg.ToToast(ToastNotificationType.Error); } hud.Dismiss(); i.Clicked += SaveBtn; }
public EventRegistrationController(IRepositoryWrapper repo, GoogleMapsService mapsService) { _repo = repo; _maps = mapsService; }
public EventController(IRepositoryWrapper repo, GoogleMapsService mapsService, MailKitService email) { _repo = repo; _maps = mapsService; _email = email; }
public MessageFactory(StatementRandomiser sr, GoogleMapsService googleMaps, ILogger <MessageFactory> logger) { _sr = sr; _googleMaps = googleMaps; _logger = logger; }
public ActionResult New(TerritoryMapViewModel territoryMapViewModel) { try { var locationService = new GoogleLocationService(ConfigurationManager.AppSettings["GooglePlaceAPIKey"]); var googleMapsService = new GoogleMapsService(ConfigurationManager.AppSettings["GooglePlaceAPIKey"]); ApplicationUser user = GetUser(); var householdersToVisit = GetHouseholdersToVisit(territoryMapViewModel, user); //Vou mudar isso para refletir as mudanças no algoritmo de montagem dos mapas territoryMapViewModel.MaxNumberOfHouseholders = 5; territoryMapViewModel.MaxDistanceAmongHouseholders = 5000; if (householdersToVisit == null) { return(View("NotAvailableHouseholders")); } var newTerritoryMap = new TerritoryMap() { CongregationId = user.CongregationId, Neighbourhood = territoryMapViewModel.selectedNeighbourhood, Householders = new List <Householder>(), UserId = user.Id }; if (householdersToVisit.Count > 0) { var firstHouseholderToVisit = householdersToVisit.First(); newTerritoryMap.Householders.Add(firstHouseholderToVisit); householdersToVisit.Remove(firstHouseholderToVisit); for (int i = 0; newTerritoryMap.Householders.Count() < territoryMapViewModel.MaxNumberOfHouseholders && i < householdersToVisit.Count(); i++) { var distance = googleMapsService.GetDistance(new LatLng((decimal)firstHouseholderToVisit.Latitude, (decimal)firstHouseholderToVisit.Longitude), new LatLng((decimal)householdersToVisit[i].Latitude, (decimal)householdersToVisit[i].Longitude)); if (distance <= territoryMapViewModel.MaxDistanceAmongHouseholders) { newTerritoryMap.Householders.Add(householdersToVisit[i]); } } _context.TerritoryMaps.Add(newTerritoryMap); _context.SaveChanges(); } else { return(View("NoMap")); } return(RedirectToAction("Index")); } catch (Exception e) { System.Threading.Thread.Sleep(1000); return(New(territoryMapViewModel)); } }
public CustomerController(ApplicationDbContext context, GoogleMapsService googleMapsService) { _context = context; _googleMapsService = googleMapsService; }
public void ProcessRequest(HttpContext context) { var dataservice = new SHIPProfileDAL(); var ds = new Agency(); //SetPortalId(context.Request); HttpResponse response = context.Response; response.ContentType = "application/json"; var localPath = context.Request.Url.LocalPath; //if (localPath.Contains("/GeoProgramSearch/svc/SHIPprofileAgencies")) //{ // JToken root; // using (var reader = new StreamReader(context.Request.InputStream)) // root = JObject.Parse(reader.ReadToEnd()); // var State = root.SelectToken("ddlStates").Value<string>(); // string ProfileSet = JsonConvert.SerializeObject(dataservice.GetSHIPProfileAgencyDetails(State)); // response.Write(ProfileSet); //} if (localPath.Contains("/GeoProgramSearch/svc/SHIPprofileAgencies")) { JToken root; using (var reader = new StreamReader(context.Request.InputStream)) root = JObject.Parse(reader.ReadToEnd()); var Latitude = Convert.ToDouble((root.SelectToken("viewData").ToList()[0].First).ToString()); var Longitude = Convert.ToDouble((root.SelectToken("viewData").ToList()[1].First).ToString()); var state = (root.SelectToken("viewData").ToList()[2].First).ToString(); var radius = int.Parse((root.SelectToken("viewData").ToList()[3].First).ToString()); string ProfileSet = JsonConvert.SerializeObject(dataservice.GetSHIPProfileAgencyDetailsByAddress(Latitude, Longitude, state, radius)); response.Write(ProfileSet); } else if (localPath.Contains("/GeoProgramSearch/svc/ResolveAddress")) { JToken root; using (var reader = new StreamReader(context.Request.InputStream)) root = JObject.Parse(reader.ReadToEnd()); var Address = root.SelectToken("textBoxAddress").Value <string>(); var googleMapsService = new GoogleMapsService(ConfigurationManager.AppSettings["GoogleApiKey"]); var latLng = googleMapsService.GetLocation(Address); string latLngVal = JsonConvert.SerializeObject(latLng); response.Write(latLngVal); } else if (localPath.Contains("/GeoProgramSearch/svc/FillPdf")) { JToken root; using (var reader = new StreamReader(context.Request.InputStream)) root = JObject.Parse(reader.ReadToEnd()); var StateFIPS = root.SelectToken("StateId").Value <string>(); var IsLoggedIn = root.SelectToken("IsLoggedIn").Value <string>(); GeneratePDF(context); // var FillPDFDataService = new } else { response.Write(JsonConvert.SerializeObject(string.Empty)); } }
public ContractorController(ApplicationDbContext context, TwilioService twilioService, GoogleMapsService googleMapsService) { _context = context; _twilioService = twilioService; _googleMapsService = googleMapsService; }
public async Task <IHttpActionResult> PostUploadExcellFiles() { if (!Request.Content.IsMimeMultipartContent()) { return(BadRequest()); } var provider = new MultipartMemoryStreamProvider(); string path = null; Tuple <byte[], HttpContent> fileArrayAndFileHttpContent = await GetFileArrayAndFileHttpContentFromProvider(provider); var filename = GetFilename(fileArrayAndFileHttpContent.Item2); filename += Guid.NewGuid() + ".xlsx"; path = Path.Combine(HttpContext.Current.Server.MapPath("~" + ConfigurationSettingsModule.GetItem("Temp")), filename); if (!Directory.Exists(HttpContext.Current.Server.MapPath("~" + ConfigurationSettingsModule.GetItem("Temp")))) { Directory.CreateDirectory( HttpContext.Current.Server.MapPath("~" + ConfigurationSettingsModule.GetItem("Temp"))); } using (FileStream fs = new FileStream(path, FileMode.Create)) { fs.Write(fileArrayAndFileHttpContent.Item1, 0, fileArrayAndFileHttpContent.Item1.Length); } try { ExcellParser excellParser = new ExcellParser(path); var veteranMappings = excellParser.GetVeterans(); foreach (var veteranMapping in veteranMappings) { var veteranBindingModel = Mapper.Map <VeteranMapping, VeteranBindingModel>(veteranMapping); var listParsedUrls = UrlParser.Parse(veteranMapping.UrlImages); veteranBindingModel.Images = UrlParser.DownloadFromUrls(listParsedUrls); var veteran = Mapper.Map <VeteranBindingModel, Veteran>(veteranBindingModel); veteran.User = _userService.GetById(User.Identity.GetUserId()); var googleMapsService = new GoogleMapsService(string.Empty); var latLng = googleMapsService.GetLatLng(veteran.BirthPlace); veteran.Latitude = latLng.Latitude; veteran.Longitude = latLng.Longitude; _veteranService.Add(veteran); } } catch (Exception exception) { var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent("Problems with parsing the file"), ReasonPhrase = "File Not Parsed" }; _logger.Error(exception); throw new HttpResponseException(resp); } finally { if (File.Exists(path)) { File.Delete(path); } } return(Ok()); }
static Program() { StoryController = new StoryController(); GMapsService = new GoogleMapsService(); }
public PlaceService(IGeoLoactionService geoLocationService, GoogleMapsService googleMapsService) { _GeoLocationService = geoLocationService; _GoogleMapsService = googleMapsService; }