private static AvailabilityPingResponse StructureTheResponse( AvailabilityPingContext pingCtx, Counts makeLevelMatchCounts, Counts makeModelLevelMatchCounts, Counts trimLevelMatchCount) { return(new AvailabilityPingResponse { PingContext = pingCtx, Availability = new { new_cars = new { by_make = new { count = makeLevelMatchCounts.NewCars }, by_make_model = new { count = makeModelLevelMatchCounts.NewCars }, by_trim = new { count = trimLevelMatchCount.NewCars } }, used_cars = new { by_make = new { count = makeLevelMatchCounts.UsedCars }, by_make_model = new { count = makeModelLevelMatchCounts.UsedCars }, by_trim = new { count = trimLevelMatchCount.UsedCars } } } }); }
private static Task <Counts> GetMakeModelLevelMatchCounts(AvailabilityPingContext pingCtx) { if (pingCtx.MakeId.IsNullOrEmpty() || pingCtx.Model.IsNullOrEmpty()) { return(Task.Run(() => new Counts())); } return(Task.Run(() => { var newMakesTask = CarsForSaleService.SearchAsync(new SearchCriteria { Zipcode = pingCtx.Zipcode, MakeModelComboFilter = new MakeModelComboFilter(String.Empty, String.Format("{0}~{1}", pingCtx.MakeId, pingCtx.Model)), TrimIdFilter = new TrimIdFilter(pingCtx.TrimId), NewStatusFilter = new NewStatusFilter(NewStatusFilter.Status.New) }); var usedMakesTask = CarsForSaleService.SearchAsync(new SearchCriteria { Zipcode = pingCtx.Zipcode, MakeModelComboFilter = new MakeModelComboFilter(String.Empty, String.Format("{0}~{1}", pingCtx.MakeId, pingCtx.Model)), TrimIdFilter = new TrimIdFilter(pingCtx.TrimId), NewStatusFilter = new NewStatusFilter(NewStatusFilter.Status.Used) }); newMakesTask.Wait(); usedMakesTask.Wait(); var newMakes = newMakesTask.Result; var usedMakes = usedMakesTask.Result; return new Counts { NewCars = newMakes.InventoryCount, UsedCars = usedMakes.InventoryCount }; })); }