public Task <Response <GetRecommendStrokeResponse[]> > GetRecommendStroke([FromBody] GetRecommendStrokeRequest request) { return(this.strokeService.GetRecommendStroke(request)); }
/// <summary> /// 获取推荐行程 /// </summary> /// <param name="request">The request.</param> /// <returns>Task<Response<GetRecommendStokeResponse>>.</returns> /// <exception cref="NotImplementedException"></exception> public async Task <Response <GetRecommendStrokeResponse[]> > GetRecommendStroke(GetRecommendStrokeRequest request) { var cityName = "杭州市"; if (request.CityId != 0) { var cityInfo = await this.strokeContext.Cities.FirstOrDefaultAsync(x => x.Id == request.CityId); cityName = cityInfo.Name; } var strokeInfo = await this.strokeContext.Strokes.WhereIf(request.CurrentCity, x => x.City.Contains(cityName)) .Where(x => x.IsRecommend) .Select(x => new GetRecommendStrokeResponse { Id = x.Id, Title = x.Title, City = x.City, Destination = x.Destination, ImageUrl = x.ImageUrl, ImageThumb = x.ImageThumb }).ToArrayAsync(); if (strokeInfo.Count() == 0) { strokeInfo = await this.strokeContext.Strokes.WhereIf(request.CurrentCity, x => x.City.Contains("杭州市")) .Where(x => x.IsRecommend) .Select(x => new GetRecommendStrokeResponse { Id = x.Id, Title = x.Title, City = x.City, Destination = x.Destination, ImageUrl = x.ImageUrl, ImageThumb = x.ImageThumb }).ToArrayAsync(); } return(new Response <GetRecommendStrokeResponse[]> { Data = strokeInfo }); }