public async Task <IActionResult> MatchLandProperty([FromRoute] int?firmId, [FromBody] LandPropertyQuery query) { if (firmId == null) { return(await MatchLandProperty(query)); } else { return(await MatchLandPropertyByFirm((int)firmId, query)); } }
public async Task <IActionResult> MatchLandProperty(LandPropertyQuery query) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var propertyList = await _manager.GetAllActiveLandProperties(); var result = _match.MatchOnLandProperty(query, propertyList); string stringQuery = $"Land Area: {query.area}. max price: {query.maxPrice}, min price: {query.minPrice}"; string location = $"{query.City}, {query.State}"; _manager.UpdateSearchQueryToLog(stringQuery, location, PropertyType.LandProperty, 0, result.Count); return(Ok(result.OrderByDescending(m => m.Rank))); }
public List <LandPropertyIndex> MatchOnLandProperty(LandPropertyQuery query, List <LandProperty> landProperties) { List <LandPropertyIndex> indexedPropertyList = new List <LandPropertyIndex>(); landProperties = landProperties.Where(m => m.State.ToLower() == query.State.ToLower()).ToList(); foreach (var item in landProperties) { double areaRank = AreaSizeRank(query.area, item.AreaSize); double pricePoint = PriceRank(item.Price, query.minPrice, query.maxPrice); var propertyIndex = new LandPropertyIndex() { Id = item.Id, ImageLink1 = item.ImageLink1, ImageLink2 = item.ImageLink2, ImageLink3 = item.ImageLink3, City = item.City, State = item.State, Name = item.Name, Price = item.Price, IsActive = item.IsActive, AreaSize = item.AreaSize, }; propertyIndex.Rank = areaRank + pricePoint; if (item.City.ToLower() == query.City.ToLower()) { propertyIndex.Rank = propertyIndex.Rank + locationScore; } indexedPropertyList.Add(propertyIndex); } return(indexedPropertyList); }