public HttpResponseMessage GetAllAddressesInRadius(LatLngRadiusRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } var response = new ItemsResponse <AddressDistanceDomain> { Items = _AddressService.GetAddressesInRadius(model) }; return(Request.CreateResponse(HttpStatusCode.OK, response)); }
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public List <AddressDistanceDomain> GetAddressesInRadius(LatLngRadiusRequest model) { List <AddressDistanceDomain> addressList = null; try { DataProvider.ExecuteCmd(GetConnection, "Address_FindInRadius" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@latpoint", model.Latitude); paramCollection.AddWithValue("@lngpoint", model.Longitude); paramCollection.AddWithValue("@radius", model.Radius); } , map : delegate(IDataReader reader, short set) { var singleAddress = new AddressDistanceDomain(); int startingIndex = 0; //startingOrdinal singleAddress.AddressId = reader.GetSafeInt32(startingIndex++); singleAddress.CompanyId = reader.GetSafeInt32(startingIndex++); singleAddress.Date = reader.GetSafeDateTime(startingIndex++); singleAddress.Address1 = reader.GetSafeString(startingIndex++); singleAddress.City = reader.GetSafeString(startingIndex++); singleAddress.State = reader.GetSafeString(startingIndex++); singleAddress.ZipCode = reader.GetSafeString(startingIndex++); singleAddress.Latitude = reader.GetSafeDecimal(startingIndex++); singleAddress.Longitude = reader.GetSafeDecimal(startingIndex++); singleAddress.Slug = reader.GetSafeString(startingIndex++); singleAddress.AddressType = reader.GetSafeInt32(startingIndex++); singleAddress.Distance = (Decimal)reader.GetSafeDouble(startingIndex++); if (addressList == null) { addressList = new List <AddressDistanceDomain>(); } addressList.Add(singleAddress); }); } catch (Exception ex) { throw ex; } return(addressList); }