static void Main(string[] args) { var apiKey = ExampleUtils.GetApiKey(args); var client = new Client(apiKey); var query = new LocationQuery(StreetLine1, StreetLine2, City, StateCode, PostalCode); Response <ILocation> response; try { response = client.FindLocations(query); } catch (FindException) { System.Console.Out.WriteLine("ReverseAddress lookup for {0}; {1}; {2}; {3}; {4} failed!", StreetLine1, StreetLine2, City, StateCode, PostalCode); throw; } if ((response != null) && (response.IsSuccess)) { var results = response.Results; System.Console.Out.WriteLine("ReverseAddress lookup for {0}; {1}; {2}; {3}; {4} was successful, returning {5} root location objects.{6}{6}", StreetLine1, StreetLine2, City, StateCode, PostalCode, results.Count, System.Environment.NewLine); foreach (var location in results) { ExampleUtils.DumpLocation(location, 2); System.Console.Out.WriteLine(); } } #if DEBUG System.Console.Out.WriteLine("Press the ENTER key to quit..."); System.Console.In.ReadLine(); #endif }
public async Task <IEnumerable <Location> > GetAllAsync() { using (var connection = context.CreateConnection()) { return(await connection.QueryAsync <Location>(LocationQuery.All())); } }
private void PostJobAds(IEmployer employer, Country country, string location) { var locationReference = new LocationReference(); LocationQuery.ResolveLocation(locationReference, country, location); PostJobAds(employer, country, locationReference); }
public async Task DeleteAsync(Guid id) { using (var connection = context.CreateConnection()) { await connection.ExecuteAsync(LocationQuery.Delete(id)); } }
private static void AddTitles(ICollection <string> titles, Country country, string location) { var locationReference = new LocationReference(); LocationQuery.ResolveLocation(locationReference, country, location); AddTitles(titles, country, locationReference); }
public ViewHolder(LocationQuery v, Action <RecyclerClickEventArgs> clickListener) : base(v) { mLocView = v; mLocView.Click += (sender, e) => clickListener(new RecyclerClickEventArgs { View = mLocView, Position = AdapterPosition }); }
public PostsController(AppDb db) { Db = db; userQuery = new UserDbQuery(Db); postQuery = new PostDbQuery(Db); authorizationQuery = new AuthorizationQuery(Db); threadQuery = new ThreadDbQuery(Db); locationQuery = new LocationQuery(Db); }
public async Task <Location> GetByIdAsync(Guid id) { using (var connection = context.CreateConnection()) { var query = await connection.QueryAsync <Location>(LocationQuery.ById(id)); return(query.SingleOrDefault()); } }
public async Task <Location> UpdateAsync(Location location) { using (var connection = context.CreateConnection()) { await connection.ExecuteAsync(LocationQuery.Update(location)); return(location); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); AddStyleSheetReference(StyleSheets.WillingnessToRelocate); rptrCounties.DataSource = LocationQuery.GetCountries(); rptrCounties.DataBind(); }
public async Task <QueryResult <StateDetailsViewModel> > GetStateList(LocationQuery queryObj) { var result = new QueryResult <StateDetailsViewModel>(); var query = (from st in _context.States join co in _context.Countries on st.CountryId equals co.Id into StatesCountry //do left join from sc in StatesCountry.DefaultIfEmpty() select new { Id = st.Id, StateCode = st.Code, Description = st.Description, StateName = st.Name, CountryName = sc.Name, CountryId = sc.Id, Deleted = st.Deleted }) .Where(x => x.Deleted != true) .ToList().Select((s, index) => new StateDetailsViewModel() { SerialNumber = index + 1, Id = s.Id, StateCode = s.StateCode, Description = s.Description, StateName = s.StateName, CountryName = s.CountryName, CountryId = s.CountryId }) .AsQueryable(); if (!string.IsNullOrEmpty(queryObj.Name)) { query = query.Where(v => v.StateCode.Contains(queryObj.Name) | v.StateName.Contains(queryObj.Name) | v.Description.Contains(queryObj.Name)); } //string key of the dictionary must be equal the column title in the ui. Value of the dictionary must be a valid column in db/query var columnsMap = new Dictionary <string, Expression <Func <StateDetailsViewModel, object> > >() { ["Code"] = v => v.StateCode, ["Name"] = v => v.StateName, ["Description"] = v => v.Description, ["CountryName"] = v => v.CountryName }; query = query.ApplyOrdering(queryObj, columnsMap); result.TotalItems = query.Count(); //query = query.ApplyPaging(queryObj); result.Items = query.ToList(); return(result); }
// Create new views (invoked by the layout manager) public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) { // create a new view LocationQuery v = new LocationQuery(parent.Context) { // set the view's size, margins, paddings and layout parameters LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent) }; return(new ViewHolder(v, OnClick)); }
private void DrawSearchBar() { searchString = GUI.TextField(new Rect(0, 0, 300, 40), searchString); if (GUI.Button(new Rect(305, 0, 100, 40), "Search")) { locationQuery = new LocationQuery(); locationQuery.QueryDone += LocationQuery_QueryDone; locationQuery.SearchLocation(searchString); SetDirty(); } }
public MeetingInfoController( UserManager <User> userManager, MeetingManager meetingManager, MeetingQuery meetingQuery, LocationQuery locationQuery ) { _meetingManager = meetingManager; _userManager = userManager; _meetingQuery = meetingQuery; _locationQuery = locationQuery; }
public Location Create(Location location) { if (location.Id == Guid.Empty) { location.Id = Guid.NewGuid(); } using (var connection = context.CreateConnection()) { connection.Execute(LocationQuery.Insert(location)); return(location); } }
public async Task <Location> CreateAsync(Location location) { if (location.Id == Guid.Empty) { location.Id = Guid.NewGuid(); } using (var connection = context.CreateConnection()) { await connection.ExecuteAsync(LocationQuery.Insert(location)); return(location); } }
public void ItShouldPrintAHumanReadableLocationQuery() { var q = new LocationQuery("1301 5th Ave", "Ste 1600", "Seattle", "WA", "98101"); var s = q.ToString(); Console.Out.WriteLine(s); Assert.IsTrue(s.StartsWith("LocationQuery")); Assert.IsTrue(s.Contains("1301 5th Ave")); Assert.IsTrue(s.Contains("Ste 1600")); Assert.IsTrue(s.Contains("Seattle")); Assert.IsTrue(s.Contains("WA")); Assert.IsTrue(s.Contains("98101")); }
private void RenderEditorPanel() { if (!_isEditable) { return; } bool doShow = UserRelocationPreference != RelocationPreference.No; divRelocationArea.Style["display"] = doShow ? "" : "none"; rptrCounties.DataSource = LocationQuery.GetCountries(); rptrCounties.DataBind(); }
public MeetingManageController( UserManager <User> userManager, MeetingManager meetingManager, MeetingQuery meetingQuery, LocationQuery locationQuery, FileService fileService ) { _userManager = userManager; _meetingManager = meetingManager; _meetingQuery = meetingQuery; _locationQuery = locationQuery; _fileService = fileService; }
public async Task <QueryResult <CountryDetailsDto> > GetCountryList(LocationQuery queryObj) { var result = new QueryResult <CountryDetailsDto>(); var query = (from co in _context.Countries select new { Id = co.Id, Code1 = co.Code1, Code2 = co.Code2, Description = co.Description, Name = co.Name, Deleted = co.Deleted }) .Where(x => x.Deleted != true) .ToList().Select((s, index) => new CountryDetailsDto() { SerialNumber = index + 1, Id = s.Id, Code1 = s.Code1, Code2 = s.Code2, Description = s.Description, Name = s.Name, }) .AsQueryable(); if (!string.IsNullOrEmpty(queryObj.Name)) { query = query.Where(v => v.Code1.Contains(queryObj.Name) | v.Code2.Contains(queryObj.Name) | v.Name.Contains(queryObj.Name) | v.Description.Contains(queryObj.Name)); } //string key of the dictionary must be equal the column title in the ui. Value of the dictionary must be a valid column in db/query var columnsMap = new Dictionary <string, Expression <Func <CountryDetailsDto, object> > >() { ["Code1"] = v => v.Code1, ["Code2"] = v => v.Code2, ["Name"] = v => v.Name, ["Description"] = v => v.Description, }; query = query.ApplyOrdering(queryObj, columnsMap); result.TotalItems = query.Count(); // query = query.ApplyPaging(queryObj); result.Items = query.ToList(); return(result); }
public override Response <ILocation> FindLocations(LocationQuery query) { if (this.ForceErrorResult) { throw new FindException("Stubbed client always errors!"); } var results = new List <ILocation>(); if (!this.ForceEmptyResult) { results.Add(_location); } return(new Response <ILocation>(this, results, GetDictionary(this), _emptyMessages)); }
private async Task <List <LocationQuery> > GetLocationList() { lstLocation = new List <LocationQuery>(); _location1 = new LocationQuery(); _location1.Id = 1; _location1.CustomerName = "Nome do cliente 1"; _location1.MovieName = "Nome do Filme 1"; _location1.LocationDate = DateTime.Now.Date; _location1.DevolutionDate = DateTime.Now.Date.AddDays(2); _location2 = new LocationQuery(); _location2.Id = 2; _location2.CustomerName = "Nome do cliente 2"; _location2.MovieName = "Nome do Filme 2"; _location2.LocationDate = DateTime.Now.Date; _location2.DevolutionDate = DateTime.Now.Date.AddDays(2); _location3 = new LocationQuery(); _location3.Id = 3; _location3.CustomerName = "Nome do cliente 3"; _location3.MovieName = "Nome do Filme 3"; _location3.LocationDate = DateTime.Now.Date; _location3.DevolutionDate = DateTime.Now.Date.AddDays(2); _location4 = new LocationQuery(); _location4.Id = 4; _location4.CustomerName = "Nome do cliente 4"; _location4.MovieName = "Nome do Filme 4"; _location4.LocationDate = DateTime.Now.Date; _location4.DevolutionDate = DateTime.Now.Date.AddDays(2); _location5 = new LocationQuery(); _location5.Id = 5; _location5.CustomerName = "Nome do cliente 5"; _location5.MovieName = "Nome do Filme 5"; _location5.LocationDate = DateTime.Now.Date.AddDays(-10); _location5.DevolutionDate = DateTime.Now.Date.AddDays(-5); lstLocation.Add(_location1); lstLocation.Add(_location2); lstLocation.Add(_location3); lstLocation.Add(_location4); lstLocation.Add(_location5); return(await Task.FromResult(lstLocation)); }
private void LoadSavedLocations() { // Load the locations from the hidden field. int[] locationIds = StringUtils.ParseArrayFromString <int>(",", hidSuggestionIds.Value); if (!locationIds.IsNullOrEmpty()) { var locations = new NamedLocation[locationIds.Length]; for (int i = 0; i < locations.Length; i++) { locations[i] = LocationQuery.GetNamedLocation(locationIds[i], true); } rptLocations.DataSource = locations; DataBind(); } }
public Response <ILocation> SearchProApi(string streetAddress, string city, string state, string postalCode) { Response <ILocation> response; var apiKey = ConfigurationManager.AppSettings["api_key"]; var client = new Client(apiKey); var query = new LocationQuery(streetAddress, null, city, state, postalCode); try { response = client.FindLocations(query); } catch (FindException) { throw new Exception(String.Format("ReverseAddress lookup for {0} {1} {2} {3} failed!", streetAddress, city, state, postalCode)); } return(response); }
private void PerformSearch(ref int index, Country country, int?distance, string location, IList <string> titles) { // Create member. var member = CreateMember(++index); // Create a job search. var locationReference = LocationQuery.ResolveLocation(country, location); CreateTestSavedJobSearchAlert(member, null, locationReference, distance, DateTime.Now.AddDays(-1)); // Get the email. Execute(true); var email = _emailServer.AssertEmailSent(); Assert.IsNotNull(email, "No email or jobs found."); AssertTitles(email, titles, titles.Count, true); }
public int PartialUpdate([FromRoute] string id, [FromBody] JsonMergePatchDocument <Location> patch) { Guid docId = new Guid(id); var ops = new List <string>(); patch.Operations.ForEach(op => { ops.Add(op.path.TrimStart('/')); }); var data = new Location(); patch.ApplyTo(data); var query = new LocationQuery(); //return query.Update(docId, data); return(query.PartialUpdate(docId, data, ops)); }
protected override void OnInit(EventArgs e) { ErrorMessage = ValidationErrorMessages.REQUIRED_FIELD_COUNTRY; ddlCountry.DataSource = LocationQuery.GetCountries(); ddlCountry.DataTextField = "Name"; ddlCountry.DataValueField = "Id"; DataBind(); if (includeGlobal) { ddlCountry.Items.Insert(0, new ListItem("Global", "255")); } // Set the default selected country based on the current request. SelectedValue = ActivityContext.Current.Location.Country; base.OnInit(e); }
/// <summary> /// Test Find using the Query class /// </summary> private void Step_30_TestFindByQuery_Generated() { using (TransactionManager tm = CreateTransaction()) { //Insert Mock Instance Location mock = CreateMockInstance(tm); bool result = DataRepository.LocationProvider.Insert(tm, mock); Assert.IsTrue(result, "Could Not Test FindByQuery, Insert Failed"); LocationQuery query = new LocationQuery(); query.AppendEquals(LocationColumn.StkId, mock.StkId.ToString()); query.AppendEquals(LocationColumn.LocId, mock.LocId.ToString()); query.AppendEquals(LocationColumn.Description, mock.Description.ToString()); query.AppendEquals(LocationColumn.Status, mock.Status.ToString()); TList <Location> results = DataRepository.LocationProvider.Find(tm, query); Assert.IsTrue(results.Count == 1, "Find is not working correctly. Failed to find the mock instance"); } }
private LocationReplacementViewModel ValidateLocationLevelForReplacement( LocationQuery locationQuery, GeographicLevel geographicLevel, ReplacementSubjectMeta replacementSubjectMeta) { var queryProperty = typeof(LocationQuery).GetProperty(geographicLevel.ToString()); if (queryProperty == null || queryProperty.GetMethod == null) { throw new ArgumentException( $"{nameof(locationQuery)} does not have a property {geographicLevel.ToString()} with get method"); } var originalCodes = ( queryProperty.GetMethod.Invoke(locationQuery, new object[] { }) as IEnumerable <string> ?? new List <string>() ).ToList(); if (!originalCodes.Any()) { return(new LocationReplacementViewModel( label: geographicLevel.GetEnumLabel(), observationalUnits: new List <ObservationalUnitReplacementViewModel>() )); } var locations = _locationService.GetObservationalUnits(geographicLevel, originalCodes); var replacementLocations = replacementSubjectMeta.ObservationalUnits .GetValueOrDefault(geographicLevel) ?.ToDictionary(location => location.Code) ?? new Dictionary <string, IObservationalUnit>(); return(new LocationReplacementViewModel( label: geographicLevel.GetEnumLabel(), observationalUnits: locations .Select(location => ValidateLocationForReplacement(location, replacementLocations)) .OrderBy(location => location.Label, LabelComparer) )); }
public IEnumerable <ClosestLocation> GetClosestLocations(LocationQuery query) { IEnumerable <ClosestLocation> ret = null; using (var connection = new SqlConnection(_config[CONNECTION_STRING])) { var cmd = connection.CreateCommand(); cmd.CommandText = "GetClosestLocations"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@lat", query.Latitude); cmd.Parameters.AddWithValue("@lon", query.Longitude); cmd.Parameters.AddWithValue("@count", query.MaxRecordsToReturn.HasValue ? query.MaxRecordsToReturn : 10); cmd.Parameters.AddWithValue("@distance", query.Distance.HasValue ? query.Distance : 10); if (cmd.Connection.State != ConnectionState.Open) { cmd.Connection.Open(); } ret = cmd.ExecuteReader().DataReaderMapToList <ClosestLocation>(); } return(ret); }