Ejemplo n.º 1
0
        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
        }
Ejemplo n.º 2
0
 public async Task <IEnumerable <Location> > GetAllAsync()
 {
     using (var connection = context.CreateConnection())
     {
         return(await connection.QueryAsync <Location>(LocationQuery.All()));
     }
 }
Ejemplo n.º 3
0
        private void PostJobAds(IEmployer employer, Country country, string location)
        {
            var locationReference = new LocationReference();

            LocationQuery.ResolveLocation(locationReference, country, location);
            PostJobAds(employer, country, locationReference);
        }
Ejemplo n.º 4
0
 public async Task DeleteAsync(Guid id)
 {
     using (var connection = context.CreateConnection())
     {
         await connection.ExecuteAsync(LocationQuery.Delete(id));
     }
 }
Ejemplo n.º 5
0
        private static void AddTitles(ICollection <string> titles, Country country, string location)
        {
            var locationReference = new LocationReference();

            LocationQuery.ResolveLocation(locationReference, country, location);
            AddTitles(titles, country, locationReference);
        }
Ejemplo n.º 6
0
 public ViewHolder(LocationQuery v, Action <RecyclerClickEventArgs> clickListener)
     : base(v)
 {
     mLocView        = v;
     mLocView.Click += (sender, e) => clickListener(new RecyclerClickEventArgs {
         View = mLocView, Position = AdapterPosition
     });
 }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
        public async Task <Location> GetByIdAsync(Guid id)
        {
            using (var connection = context.CreateConnection())
            {
                var query = await connection.QueryAsync <Location>(LocationQuery.ById(id));

                return(query.SingleOrDefault());
            }
        }
Ejemplo n.º 9
0
        public async Task <Location> UpdateAsync(Location location)
        {
            using (var connection = context.CreateConnection())
            {
                await connection.ExecuteAsync(LocationQuery.Update(location));

                return(location);
            }
        }
Ejemplo n.º 10
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            AddStyleSheetReference(StyleSheets.WillingnessToRelocate);

            rptrCounties.DataSource = LocationQuery.GetCountries();
            rptrCounties.DataBind();
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        // 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));
        }
Ejemplo n.º 13
0
 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;
 }
Ejemplo n.º 15
0
        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);
            }
        }
Ejemplo n.º 16
0
        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);
            }
        }
Ejemplo n.º 17
0
        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"));
        }
Ejemplo n.º 18
0
        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;
 }
Ejemplo n.º 20
0
        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));
        }
Ejemplo n.º 23
0
        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();
            }
        }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 25
0
        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);
        }
Ejemplo n.º 26
0
        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));
        }
Ejemplo n.º 27
0
        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);
        }
Ejemplo n.º 28
0
        /// <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)
                       ));
        }
Ejemplo n.º 30
0
        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);
        }