Пример #1
0
        public IActionResult Results(string searchQuery)
        {
            var posts     = _postService.GetFilteredPosts(searchQuery).ToList();
            var noResults = (!string.IsNullOrEmpty(searchQuery) && !posts.Any());

            var postListings = posts.Select(post => new PostListingVM
            {
                Id              = post.Id,
                Forum           = BuildForumListing(post),
                Author          = post.User.UserName,
                AuthorId        = post.User.Id,
                AuthorRating    = post.User.Rating,
                Title           = post.Title,
                DatePosted      = post.DateCreated.ToString(CultureInfo.InvariantCulture),
                NumberOfReplies = post.Replies.Count()
            }).OrderByDescending(post => post.DatePosted);

            var model = new SearchResultVM
            {
                EmptySearchResults = noResults,
                Posts       = postListings,
                SearchQuery = searchQuery,
            };

            return(View(model));
        }
Пример #2
0
        public ActionResult Checkout1(FilterFormVM model)
        {
            if (model.PickUpCity.Id == 0 || model.DropOffCity.Id == 0)
            {
                return(RedirectToAction("Index", "Home"));
            }

            SetBookingDataByFilterFormVM(model);

            SearchResultVM searchResult = new SearchResultVM();

            searchResult.Products                = _productService.Search(BookingData.OfferCriteria);
            searchResult.Properties              = _propertyService.GetProperties();
            searchResult.Destination             = _locationService.GetLocationByBestemmingId(BookingData.OfferCriteria.OphaalBestemmingId);
            searchResult.TotalSearchResult       = searchResult.Products.Any() ? searchResult.Products.First().Total : 0;
            searchResult.IsSearch                = true;
            searchResult.BookingData             = BookingData;
            searchResult.SelectedPropertyDetails = BookingData.OfferCriteria.EigenschapWaarden;


            var pickUpCity = BookingData.Destinations.Find(f => f.Id == BookingData.OfferCriteria.OphaalBestemmingId);

            if (pickUpCity != null)
            {
                searchResult.PickUpCityName = pickUpCity.DisplayName;
            }

            return(View(searchResult));
        }
Пример #3
0
        public SearchResultVM GetSearchResultVM(SearchBM bind)
        {
            IEnumerable <LostPet>  lostPets  = this.Context.LostPets;
            IEnumerable <FoundPet> foundPets = this.Context.FoundPets;

            IEnumerable <SearchedLostPetVM>  lostVM  = Mapper.Map <IEnumerable <LostPet>, IEnumerable <SearchedLostPetVM> >(lostPets);
            IEnumerable <SearchedFoundPetVM> foundVM = Mapper.Map <IEnumerable <FoundPet>, IEnumerable <SearchedFoundPetVM> >(foundPets);

            foreach (var lostPet in lostVM)
            {
                lostPet.SearchScore = GetLostPetSearchScore(lostPet, bind.SearchContent.ToLower());
            }

            foreach (var foundPet in foundVM)
            {
                foundPet.SearchScore = GetFoundPetSearchScore(foundPet, bind.SearchContent.ToLower());
            }

            lostVM  = lostVM.Where(p => p.SearchScore > 0).OrderByDescending(p => p.SearchScore);
            foundVM = foundVM.Where(p => p.SearchScore > 0).OrderByDescending(p => p.SearchScore);

            SearchResultVM vm = new SearchResultVM
            {
                FoundPets = foundVM,
                LostPets  = lostVM
            };

            return(vm);
        }
Пример #4
0
        private static void AddtionalInfo <T>(StringBuilder sb, SearchResultVM <T> srVM)
            where T : SearchResult
        {
            var s = srVM.SearchResult;

            if (s == null)
            {
                return;
            }
            sb.AppendLine($"SearchResult: Type={s.GetType()}, Uri={s.SearchUri}");
        }
Пример #5
0
        public async Task <SearchResultVM> Search(string query)
        {
            if (string.IsNullOrWhiteSpace(query))
            {
                throw new ArgumentNullException(nameof(query));
            }

            var model = new SearchResultVM {
                Query = query
            };

            var tasks = searchEngines
                        .Select(se => se.SearchFirst10(query))
                        .ToList();

            while (tasks.Count > 0)
            {
                var fastestTask = await Task.WhenAny(tasks);

                var searchEngine = searchEngines[tasks.IndexOf(fastestTask)];
                var engineName   = searchEngine.Name;
                if (fastestTask.IsCompletedSuccessfully)
                {
                    var count = fastestTask.Result.Count();
                    if (count > 0 && count <= 10)
                    {
                        model.EngineName    = engineName;
                        model.Items         = fastestTask.Result;
                        model.TrademarkLink = searchEngine.TrademarkLink;
                        model.AddMessage(HasFoundMessage(engineName, count));
                        break;
                    }
                    else if (count > 10)
                    {
                        model.AddMessage(Over10EngineErrorMessage(engineName));
                        tasks.Remove(fastestTask);
                    }
                    else // 0
                    {
                        model.AddMessage(NotFoundMessage(engineName));
                        tasks.Remove(fastestTask);
                    }
                }
                else //only IsFault (cancel not implemented)
                {
                    var message = IsFaultedMessage(engineName, fastestTask.Exception.InnerException.Message);
                    model.AddMessage(message);
                    tasks.Remove(fastestTask);
                }
            }

            return(model);
        }
Пример #6
0
        public ActionResult Result(DateTime Checkin, DateTime Checkout, string Location)
        {
            //ViewBag.Checkin = Checkin;
            // ViewBag.Checkout = Checkout;


            if ((Checkin == Checkout) || (Checkin < DateTime.Now) || (Checkin > Checkout))
            {
                //ViewBag.Message = "Check the date";
                return(RedirectToAction("Index", "Search"));
            }
            else
            {
                // string Locationsel = Request.Form["Location"].ToString();

                // Search the room for the locataion in the database



                List <Room> roomList = RoomManager.SearchRoom(Checkin, Checkout, Location);

                List <RoomVM> roomVMList = new List <RoomVM>();

                foreach (Room room in roomList)
                {
                    int           IdHotel     = (int)room.IdHotel;
                    Hotel         hotel       = HotelManager.GetHotel(IdHotel);
                    int           IdRoom      = (int)room.IdRoom;
                    List <string> PictureList = PictureManager.GetPictures(IdRoom);

                    roomVMList.Add(new RoomVM()
                    {
                        IdRoom      = room.IdRoom,
                        IdHotel     = room.IdHotel,
                        Website     = hotel.Website,
                        HotelName   = hotel.Name,
                        Price       = room.Price,
                        PictureList = PictureList
                    });
                }


                SearchResultVM searchResult = new SearchResultVM()
                {
                    Checkin    = Checkin,
                    Checkout   = Checkout,
                    Location   = Location,
                    roomVMList = roomVMList
                };

                return(View(searchResult));
            }
        }
Пример #7
0
        public ActionResult SearchResult(string keywords)
        {
            ViewBag.KeyWords = keywords;
            SearchResultVM searchresultvm = new SearchResultVM();

            searchresultvm.Activity = activitymanager.GetActivityByKeywords(keywords);
            searchresultvm.Goods    = goodsmanager.SelectAllGoods().Where(g => g.GoodsName.Contains(keywords));
            searchresultvm.BaiKe    = succulentmanager.SelectSucculent().Where(s => (s.SucculentName.Contains(keywords)) || (s.Feature.Contains(keywords) || (s.SucculentCategory.SucculentCategoryName.Contains(keywords))));
            searchresultvm.Posts    = postsmanager.SelectAllPosts().Where(p => (p.PostTitle.Contains(keywords)) || (p.PostContent.Contains(keywords)));

            return(View(searchresultvm));
        }
Пример #8
0
        public ActionResult _LoadMore(int page = 1, List <int> properties = null)
        {
            SearchResultVM searchResult = new SearchResultVM();

            searchResult.Products                = _productService.Search(BookingData.OfferCriteria, pageNr: page, propertyValues: properties ?? new List <int>());
            searchResult.TotalSearchResult       = searchResult.Products.Any() ? searchResult.Products.First().Total : 0;
            searchResult.BookingData             = BookingData;
            searchResult.SelectedPropertyDetails = BookingData.OfferCriteria.EigenschapWaarden;

            ViewData[GlobalStatic.Islast] = !_productService.Search(BookingData.OfferCriteria, pageNr: page + 1, propertyValues: properties ?? new List <int>()).Any();

            return(PartialView("_LoadMore", searchResult));
        }
Пример #9
0
 private void OnResultsFound(object sender, List <PriceInfo> results)
 {
     if (this.ResultViewModel == null)
     {
         this.ResultViewModel = new SearchResultVM();
     }
     if (this.ResultPage == null)
     {
         this.ResultPage = new SearchResultPage(this.ResultViewModel);
     }
     this.ResultViewModel.UpdateResults(results);
     this.PushAsync(this.ResultPage);
 }
Пример #10
0
        public async Task <ActionResult> Search(List <ResumeSearchVM> resumes, SearchVM search)
        {
            try
            {
                SearchResultVM vm = new SearchResultVM();
                if (ModelState.IsValid && resumes.Count > 0)
                {
                    var selected = resumes.Where(r => r.IsChecked).Select(x => x.Id).Single();
                    var listings = await searchService.SearchListings(selected, search.Phrase, search.Location, search.IsFullTime);

                    var listingsVM = new List <ListingVM>();

                    foreach (var l in listings)
                    {
                        listingsVM.Add(new ListingVM(l));
                    }

                    vm = new SearchResultVM()
                    {
                        Count    = listings.Count,
                        Listings = listingsVM
                    };
                }
                else
                {
                    vm.Notification = new NotificationVM()
                    {
                        Message = "Please complete steps 1 and 2",
                        Type    = NotificationType.Error
                    };
                }

                return(PartialView("~/Views/Search/SearchResultPartial.cshtml", vm));
            }
            catch (Exception ex)
            {
                logger.Log(LogType.Error, "Failed to complete search", ex);
                var vm = new SearchResultVM()
                {
                    Notification = new NotificationVM()
                    {
                        Message = "Failed to load results",
                        Type    = NotificationType.Error
                    }
                };
                return(PartialView("~/Views/Search/SearchResultPartial.cshtml", vm));
            }
        }
        public async Task <IActionResult> FineTune(SearchResultVM searchResultVM)
        {
            if (searchResultVM.Tracks.All(track => track.ChosenForFineTuning == false))
            {
                return(View("Search", searchResultVM));
            }
            try
            {
                var fineTunedResult = await _recommendationService.FineTuneRecommendation(searchResultVM);

                searchResultVM = _searchResultMapper.MapToViewModel(fineTunedResult);

                return(View("Search", searchResultVM));
            }
            catch (System.Exception)
            {
                //log exception
                return(RedirectToAction("Error"));
            }
        }
Пример #12
0
        public async Task <SpotifyRecommendationsResult> FineTuneRecommendation(SearchResultVM searchResultVM)
        {
            var listOfIds = new List <string>();

            foreach (var track in searchResultVM.Tracks)
            {
                if (track.ChosenForFineTuning)
                {
                    listOfIds.Add(track.ArtistId);
                }
            }

            //Spotify recommendation-seed only takes 5 parameters
            if (listOfIds.Count > 5)
            {
                listOfIds = listOfIds.Take(5).ToList();
            }
            string joinedIds = string.Join(",", listOfIds);

            return(await _spotifyService.GetRecommendationWithMultipleArtistsAsync(joinedIds));
        }
        public async Task Add(SearchResultVM model)
        {
            var sr = new SearchResult
            {
                Query      = model.Query,
                Date       = DateTime.Now,
                EngineName = model.EngineName,
                Items      =
                    model.Items
                    .Select(i => new FoundItem
                {
                    Title   = i.Title,
                    Snippet = i.Snippet,
                    Url     = i.Url,
                })
                    .ToList(),
            };

            db.SearchResults.Add(sr);
            await db.SaveChangesAsync();
        }
Пример #14
0
        async private void InitList(BookShelf bookshelf, ObservableCollection <Book> books)
        {
            ResultBookList = new ObservableCollection <ViewModel.SearchResultBook>();
            addResultBook(books, ResultBookList);

            SearchResultVM = new SearchResultVM {
                BookResultList = ResultBookList
            };
            this.BindingContext = SearchResultVM;

            listBook.ItemSelected += async(sender, e) =>
            {
                if (e.SelectedItem == null)
                {
                    return;
                }
                ((ListView)sender).SelectedItem = null;
                ViewModel.SearchResultBook item = e.SelectedItem as ViewModel.SearchResultBook;

                //本棚に登録済みの場合は詳細を表示しない
                if (item != null && item.IsRegistBookShelf == false)
                {
                    await Navigation.PushAsync(new BookDetailPage(bookshelf, item.CreateBook(), item.IsRegistBookShelf));
                }
            };

            listBook.ItemAppearing += async(object sender, ItemVisibilityEventArgs e) => {
                // ObservableCollection の最後が ListView の Item と一致した時に ObservableCollection にデータを追加する。
                if (ResultBookList.Last() == e.Item as SearchResultBook)
                {
                    // ObservableCollection にデータを追加する処理
                    stack.IsVisible = true;
                    await AmazonSearch(SearchContext);     // 実際の処理を入れてください。

                    stack.IsVisible = false;
                }
            };

            SearchResultVM.CheckBooks(books);
        }
Пример #15
0
        public ActionResult SearchByProperties(List <int> properties)
        {
            if (BookingData.OfferCriteria.OphaalBestemmingId == 0)
            {
                return(new EmptyResult());
            }

            SearchResultVM searchResult = new SearchResultVM();

            searchResult.Products                = _productService.Search(BookingData.OfferCriteria, propertyValues: properties ?? new List <int>());
            searchResult.TotalSearchResult       = searchResult.Products.Any() ? searchResult.Products.First().Total : 0;
            searchResult.BookingData             = BookingData;
            searchResult.SelectedPropertyDetails = BookingData.OfferCriteria.EigenschapWaarden;

            var pickUpCity = BookingData.Destinations.Find(f => f.Id == BookingData.OfferCriteria.OphaalBestemmingId);

            if (pickUpCity != null)
            {
                searchResult.PickUpCityName = pickUpCity.DisplayName;
            }

            return(PartialView("_SearchResult", searchResult));
        }
Пример #16
0
        public async Task <IActionResult> WebSearch(string query)
        {
            var model = new SearchResultVM {
                Query = query
            };

            if (string.IsNullOrWhiteSpace(query))
            {
                model.Query = null;
                model.AddMessage("Error: query is empty!");
            }
            else
            {
                model = await webSearchService.Search(query);

                if (model.Items?.Any() == true)
                {
                    await repository.Add(model);
                }
            }

            return(View("Index", model));
        }
Пример #17
0
        public BookDetailPage(BookShelf bookShelf, Book book, bool isRegist)
        {
            //GA->
            //詳細ページ表示してAmazonページをみる割合を検証する
            GoogleAnalytics.Current.Tracker.SendView("BookDetailPage");
            //GA<-

            this.Book   = book;
            CalilSearch = new SearchResultVM {
                BookResultList = GetSearchResultBookList(this.Book)
            };

            if (!isRegist)
            {
                ToolbarItems.Add(new ToolbarItem
                {
                    Text    = "[本の登録]",
                    Command = new Command(() =>
                    {
                        string readingStatus = SwitchReading.IsToggled ? "既読" : "未読";
                        bookShelf.SaveBook(book, readingStatus, EntryNote.Text);
                        //GA->
                        //膨大な蔵書を育てる人が多い事の検証。蔵書追加頻度を知りたい
                        GoogleAnalytics.Current.Tracker.SendEvent("BookDetailPage", "AddBook", book.Title);
                        //GA<-
                        LabelFooter.Text = "本を登録しました [" + DateTime.Now.ToString() + "]";
                    })
                });
            }
            else
            {
                ToolbarItems.Add(new ToolbarItem
                {
                    Text    = "[本の登録]",
                    Command = new Command(() =>
                    {
                        string readingStatus = SwitchReading.IsToggled ? "既読" : "未読";
                        bookShelf.SaveBook(book, readingStatus, EntryNote.Text);
                        //GA->
                        //膨大な蔵書を育てる人が多い事の検証。蔵書の更新頻度を知りたい
                        GoogleAnalytics.Current.Tracker.SendEvent("BookDetailPage", "UpdateBook", book.Title);
                        //GA<-
                        LabelFooter.Text = "本を登録しました [" + DateTime.Now.ToString() + "]";
                    })
                });
                ToolbarItems.Add(new ToolbarItem
                {
                    Text    = "[本の削除]",
                    Command = new Command(async() =>
                    {
                        bool ret = await DisplayAlert("本の削除", "本を削除します", "OK", "キャンセル");
                        if (!ret)
                        {
                            return;
                        }

                        bookShelf.DeleteBook(book);
                        await Navigation.PopAsync(true);
                    })
                });
            }

            Label labelFooter = new Label
            {
                Style          = Application.Current.Resources["FooterLabelStyle"] as Style,
                BindingContext = CalilSearch,
            };

            labelFooter.SetBinding(Label.TextProperty, "Status");
            LabelFooter = labelFooter;

            ScrollView scrollView = new ScrollView
            {
                Margin          = new Thickness(10, 0),
                VerticalOptions = LayoutOptions.FillAndExpand,
                Content         = GetBookDetailContent(),
            };


            Content = new StackLayout {
                Children =
                {
                    scrollView,
                    labelFooter,
                },
            };

            this.BindingContext = CalilSearch;
            CheckLibrary();
        }
Пример #18
0
 internal bool IsMatch(SearchResultVM item)
 {
     return(IsMatch(item.Text));
 }
Пример #19
0
        public ActionResult Search(SearchBM bind)
        {
            SearchResultVM vm = this.service.GetSearchResultVM(bind);

            return(View(vm));
        }
Пример #20
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            SearchResultVM vm   = this[position];
            View           view = holder.ItemView;

            ((ViewHolder)holder).svm         = vm;
            ((ViewHolder)holder).SVMPosition = position;

            if (holder.ItemViewType == 1)
            {
                view.FindViewById <TextView>(Resource.Id.captionAccent).SetText(vm.CaptionAccent, TextView.BufferType.Normal);
                return;
            }

            switch (_type)
            {
            case SRCType.Search:
                if (FoodJournal.AppModel.AppStats.Current.PremiumItemsLocked)
                {
                    if (vm.IsLocked)
                    {
                        view.FindViewById <ImageView>(Resource.Id.lockicon).Visibility = ViewStates.Visible;
                        view.FindViewById <TextView>(Resource.Id.text).SetTextColor(view.Context.Resources.GetColor(Resource.Color.SubtleTextColor));
                    }
                    else
                    {
                        view.FindViewById <ImageView>(Resource.Id.lockicon).Visibility = ViewStates.Gone;
                        view.FindViewById <TextView>(Resource.Id.text).SetTextColor(view.Context.Resources.GetColor(Resource.Color.NormalTextColor));
                    }
                    var listener = vm.Listener as SearchVM;

                    if (listener != null && string.IsNullOrEmpty(listener.Query) == false)
                    {
                        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent);
                        lp.SetMargins(25, 0, 0, 0);
                        view.FindViewById <TextView>(Resource.Id.text).LayoutParameters = lp;
                    }
                    else
                    {
                        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent);
                        lp.SetMargins(0, 0, 0, 0);
                        view.FindViewById <TextView>(Resource.Id.text).LayoutParameters = lp;
                    }
                }
                else
                {
                    view.FindViewById <ImageView>(Resource.Id.lockicon).Visibility = ViewStates.Gone;
                }
                view.FindViewById <TextView>(Resource.Id.text).SetText(vm.Text, TextView.BufferType.Normal);

                break;

            case SRCType.Properties:
            case SRCType.ServingSizes:

                view.FindViewById <TextView>(Resource.Id.text_title_dialog_copy).SetText(vm.Text, TextView.BufferType.Normal);
                var item = vm.MakeItem();
                var line = view.FindViewById <LinearLayout>(Resource.Id.layout_size_dialog_copy);
                line.RemoveAllViews();
                int i = 0;
                foreach (var SS in item.ServingSizes.Amounts)
                {
                    if (SS.amount2.IsValid)
                    {
                        var newview = View.Inflate(_context, Resource.Layout.item_dialog_copy_line, null);
                        newview.FindViewById <TextView>(Resource.Id.text_size).SetText(SS.amount1.ToString(true), TextView.BufferType.Normal);
                        newview.FindViewById <TextView>(Resource.Id.text_size2).SetText(SS.amount2.ValueString(), TextView.BufferType.Normal);
                        line.AddView(newview);
                        if (i++ > 3)
                        {
                            break;
                        }
                    }
                }
                break;
            }
        }
 protected override void When()
 {
     _searchResultVm = _searchResultMapper.MapToViewModel(_recommendationResult);
 }
Пример #22
0
        public ActionResult Checkout1(string urlNameParent, string urlName)
        {
            if (!IsNotSearch)
            {
                if (BookingData == null || BookingData.OfferCriteria == null || BookingData.OfferCriteria.OphaalBestemmingId == 0)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                SearchResultVM searchResult = new SearchResultVM();
                searchResult.Products                = _productService.Search(BookingData.OfferCriteria);
                searchResult.Properties              = _propertyService.GetProperties();
                searchResult.Destination             = _locationService.GetLocationByBestemmingId(BookingData.OfferCriteria.OphaalBestemmingId);
                searchResult.TotalSearchResult       = searchResult.Products.Any() ? searchResult.Products.First().Total : 0;
                searchResult.IsSearch                = true;
                searchResult.BookingData             = BookingData;
                searchResult.SelectedPropertyDetails = BookingData.OfferCriteria.EigenschapWaarden;

                var pickUpCity = BookingData.Destinations.Find(f => f.Id == BookingData.OfferCriteria.OphaalBestemmingId);
                if (pickUpCity != null)
                {
                    searchResult.PickUpCityName = pickUpCity.DisplayName;
                }

                return(View(searchResult));
            }
            else
            {
                var destination = _locationService.GetDestinationByUrl(urlName);
                if (destination == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                FilterFormVM model = new FilterFormVM();
                model.CarType = 10;

                model.PickUpCity = destination;
                var availableDays = _locationService.GetAvailableDays(model.PickUpCity.Id);
                if (availableDays.Count == 0)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                DateTime defaultDate = (new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 9, 0, 0).AddDays(2)).DefaultValidDate(GlobalStatic.Holidays, availableDays);


                model.PickUpTime       = defaultDate.ToString("HH:mm:ss");
                model.PickUpTimeString = defaultDate.ToString("HH:mm");
                model.StartDate        = defaultDate.ToString("dd-MM-yyyy");
                model.StartDateString  = defaultDate.ToString("dd-MM");

                model.DropOffCity = destination;

                availableDays = _locationService.GetAvailableDays(model.DropOffCity.Id);
                if (availableDays.Count == 0)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                var availableEndDate = defaultDate.AddDays(1).DefaultValidDate(GlobalStatic.Holidays, availableDays);

                model.DropOffTime       = defaultDate.ToString("HH:mm:ss");
                model.DropOffTimeString = defaultDate.ToString("HH:mm");
                model.EndDate           = availableEndDate.ToString("dd-MM-yyyy");
                model.EndDateString     = availableEndDate.ToString("dd-MM");


                SetBookingDataByFilterFormVM(model);

                SearchResultVM searchResult = new SearchResultVM();
                searchResult.Products                = _productService.Search(BookingData.OfferCriteria);
                searchResult.Properties              = _propertyService.GetProperties();
                searchResult.Destination             = _locationService.GetLocationByBestemmingId(BookingData.OfferCriteria.OphaalBestemmingId);
                searchResult.TotalSearchResult       = _productService.CountSearch(BookingData.OfferCriteria);
                searchResult.BookingData             = BookingData;
                searchResult.SelectedPropertyDetails = BookingData.OfferCriteria.EigenschapWaarden;

                var pickUpCity = BookingData.Destinations.Find(f => f.Id == BookingData.OfferCriteria.OphaalBestemmingId);
                if (pickUpCity != null)
                {
                    searchResult.PickUpCityName = pickUpCity.DisplayName;
                }

                return(View(searchResult));
            }
        }