Exemplo n.º 1
0
        public async Task <ResturantsResponse> PostPhoto()
        {
            var data = await this.Request.Content.ReadAsByteArrayAsync();

            var faces    = GetFaces(data);
            var emotions = GetEmotions(data);

            //string lat;
            //Request.Headers.TryGetValues("Lat")
            //var geoLoc = new GeoLocationParameters() {Lat =[@"Lat"], Lon = Request.Headers["Lon"]};

            var searchRequests = SearchRequestEvaluator.Evaluate(faces, emotions);
            var dataProvider   = new DoubleGisDataProvider();
            var firms          = searchRequests.Select(x => dataProvider.GetResturants(x.SearchQuery, x.Criteria));
            var defaultFirms   = dataProvider.GetResturants("", Enumerable.Empty <string>());

            var random            = new Random();
            var pickedResults     = Pick(firms.SelectMany(x => x.Variants), random.Next(4, 8)).ToArray().OrderByDescending(x => x.FlampOverallRating);
            var pickedResultNames = pickedResults.Select(x => x.Name);

            var defaultItems = Pick(defaultFirms.Variants.Where(x => !pickedResultNames.Contains(x.Name)), random.Next(2, 4)).OrderByDescending(x => x.FlampOverallRating);

            var result = new ResturantsResponse
            {
                Variants =
                    pickedResults.Concat(defaultItems)
                    .DistinctBy(x => x.Name)
                    .ToArray(),
                People = faces.Select(f => f.FaceAttributes).ToArray()
            };

            return(result);
        }
Exemplo n.º 2
0
        public async Task <ResturantsResponse> PostPhoto()
        {
            var data = await Request.Content.ReadAsByteArrayAsync();

            var faces    = GetFaces(data);
            var emotions = GetEmotions(data);

            //string lat;
            //Request.Headers.TryGetValues("Lat")
            //var geoLoc = new GeoLocationParameters() {Lat =[@"Lat"], Lon = Request.Headers["Lon"]};

            var searchRequests = SearchRequestEvaluator.Evaluate(faces, emotions);
            var dataProvider   = new DoubleGisDataProvider();
            var firms          = searchRequests.Select(x => dataProvider.GetResturants(x.SearchQuery, x.Criteria));
            var defaultFirms   = dataProvider.GetResturants("", Enumerable.Empty <string>());

            return(new ResturantsResponse()
            {
                Variants = Pick(firms.SelectMany(x => x.Variants), 5).Union(Pick(defaultFirms.Variants, 2)).DistinctBy(x => x.Name).ToArray(),
                People = faces.Select(f => f.FaceAttributes).ToArray()
            });
        }