示例#1
0
        public static void Search <T>(SearchVm search)//SearchResultVm<T>
        {
            var obj = new SearchResultVm <T>();

            /*
             * IRestClient client = new RestClient(ApiBaseUrl);
             * var request = new RestRequest(Method.POST);
             * request.Resource = "search/";
             * request.AddJsonBody(search);
             *
             * var obj = client.Execute<SearchResultVm<T>>(request).Data;
             * obj.searchWrapper.searchVm = search;
             */
            IDataReader searchResult = null;
            IList       IList;

            switch (search.SearchTable)
            {
            //case SearchCategories.APINVOICE:
            //    return PartialView("Customer", SearchService.Search<Customer>(search));

            case SearchCategories.APINVOICE:
                searchResult = new APInvoiceBO().PerformSearch(search.whereclause);
                break;
                //IList = DataReaderMapToList<NetTms.Objects.Search.Customer>(searchResult);
            }

            // return obj;
        }
        private static NearbySearchResult GetNearbySearchResult(SearchVm searchVm)
        {
            NearbySearchResult result = null;

            if (searchVm.PageType.ToSearchType() != SearchType.ProductsAndServices)
            {
                CommunitiesSearchVm communitiesSearchVm = searchVm as CommunitiesSearchVm;
                if (communitiesSearchVm != null)
                {
                    CommunityNearbySearchModel searchModel = communitiesSearchVm.ToCommunityNearbySearchModel();
                    searchModel = SearchBc.Instance.SearchNearbyCommunities(searchModel);
                    result      = searchModel.Result;
                }
            }
            else
            {
                ServiceProvidersSearchVm serviceProvidersSearchVm = searchVm as ServiceProvidersSearchVm;
                if (serviceProvidersSearchVm != null)
                {
                    NearbySearchModel searchModel2 = serviceProvidersSearchVm.ToNearbySearchModel();
                    searchModel2 = SearchBc.Instance.SearchNearbyServiceProviders(searchModel2);
                    result       = searchModel2.Result;
                }
            }
            return(result);
        }
示例#3
0
 protected void BindSearchModel(SearchVm model, ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor)
 {
     if (string.Equals(propertyDescriptor.Name, "Criteria"))
     {
         model.Criteria.CountryCode("USA");
         string text = ((string)controllerContext.RouteData.Values["stateCode"]) ?? controllerContext.HttpContext.Request["StateCode"];
         if (!string.IsNullOrWhiteSpace(text))
         {
             model.Criteria.StateCode(text.FromUrlSectionString());
         }
         string text2 = ((string)controllerContext.RouteData.Values["cityName"]) ?? controllerContext.HttpContext.Request["City"];
         if (!string.IsNullOrWhiteSpace(text2))
         {
             model.Criteria.City(text2.FromUrlSectionString());
         }
         string text3 = ((string)controllerContext.RouteData.Values["Zip"]) ?? controllerContext.HttpContext.Request["zip"];
         if (!string.IsNullOrWhiteSpace(text3))
         {
             model.Criteria.Zip(text3);
         }
     }
     if (string.Equals(propertyDescriptor.Name, "PageType"))
     {
         base.BindProperty(controllerContext, bindingContext, propertyDescriptor);
         model.Criteria.SearchType(model.PageType.ToSearchType());
     }
 }
示例#4
0
 public static string PagingUrl(SearchVm model, int pageNumber)
 {
     return(model.PageType.FluentUrl().State(model.Criteria.StateCode()).Zip(model.Criteria.Zip())
            .City(model.Criteria.City())
            .WithPaging(pageNumber)
            .Url());
 }
示例#5
0
        private async Task <SearchVm <QueueLogVm> > GetQueueLogForActivityUpload(int queueId, PaginatedQueryM query)
        {
            var orderBy   = string.IsNullOrEmpty(query.SortBy) ? nameof(DataUploadingLog.Id) : query.SortBy;
            var orderRule = query.SortAscending ? "ASC" : "DESC";
            var filtered  = _dbContext.DataUploadingLogs
                            .Where(x => x.DataSourceQueueId == queueId)
                            .OrderBy($"{orderBy} {orderRule}")
                            .GroupBy(x => x.TargetStatId);
            var total = await filtered.CountAsync();

            var result = (await filtered
                          .Skip(Pagination.CalculateSkip(query.PageSize, query.Page, total))
                          .Take(query.PageSize)
                          .AsNoTracking()
                          .ToListAsync())
                         .Select(x => new DataUploadingLog
            {
                DataSourceQueue = x.FirstOrDefault()?.DataSourceQueue,
                EndImportDate   = x.Select(y => y.EndImportDate).Max(),
                StartImportDate = x.Select(y => y.StartImportDate).Max(),
                TargetStatId    = x.FirstOrDefault()?.TargetStatId,
                StatUnitName    = x.FirstOrDefault()?.StatUnitName,
                Status          = x.Any(y => y.Status == DataUploadingLogStatuses.Error)
                        ? DataUploadingLogStatuses.Error
                        : x.Any(y => y.Status == DataUploadingLogStatuses.Warning)
                            ? DataUploadingLogStatuses.Warning
                            : DataUploadingLogStatuses.Done,
                Note = x.FirstOrDefault()?.Note,
            });

            return(SearchVm <QueueLogVm> .Create(result.Select(QueueLogVm.Create), total));
        }
示例#6
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            string tag;
            string username = null;

            if (NavigationContext.QueryString.TryGetValue("tag", out tag))
            {
                search.txtSearch.Text  = tag;
                search.rbTag.IsChecked = true;
            }
            else if (NavigationContext.QueryString.TryGetValue("username", out username))
            {
                search.txtSearch.Text   = username;
                search.rbUser.IsChecked = true;
            }


            if (tag != null || username != null)
            {
                SearchVm.Search(null, username, tag, (vm) =>
                {
                    this.DataContext = vm;
                });
            }
            base.OnNavigatedTo(e);
        }
示例#7
0
 public HttpResponseMessage Put(SearchVm value)
 {
     try
     {
         var start  = DateTime.Now;
         var models = this.organizationService.Get(value.ToModel());
         var end    = DateTime.Now;
         Debug.WriteLine("Get orgs time: " + end.Subtract(start));
         start = DateTime.Now;
         var result = new List <OrganizationVm>();
         foreach (var org in models)
         {
             result.Add(OrganizationVm.FromModel(org));
         }
         // Return the new item, inside a 201 response
         var response = Request.CreateResponse(HttpStatusCode.OK, result);
         end = DateTime.Now;
         Debug.WriteLine("Convert orgs time: " + end.Subtract(start));
         return(response);
     }
     catch (Exception e) {
         emailHelper.SendErrorEmail(e);
     }
     return(Request.CreateResponse(HttpStatusCode.NotFound));
 }
示例#8
0
        public ActionResult Search(SearchVm searchVm)
        {
            if (searchVm.Page < 0)
            {
                throw new ArgumentException("Page less than 0");
            }

            bool isLastPage, isFirstPage;
            var  articles = _articleService.GetArticlesForPage(pageSize, searchVm.Page, out isLastPage,
                                                               out isFirstPage, x => x.Rating, _articleService.SearchArticles(searchVm.SearchText));

            if (articles == null)
            {
                return(new EmptyResult());
            }

            var posts = Mapper.Map <IEnumerable <Article>, IEnumerable <PostIndexVm> >(articles);

            SearchVm vmBack = new SearchVm()
            {
                Page = searchVm.Page - 1, SearchText = searchVm.SearchText
            };

            searchVm.Page += 1;

            var vm = new PostsListVm()
            {
                UrlNext   = Url.Action("Search", "Home", searchVm),
                UrlBack   = Url.Action("Search", "Home", vmBack),
                PostsList = posts, IsLastPage = isLastPage, IsFirstPage = isFirstPage
            };

            return(PartialView("../Post/_PostsList", vm));
        }
示例#9
0
        public IActionResult Index(SearchVm vm)
        {
            _sessionService.SetLastPage("search/find-a-service");

            ViewBag.BackLink = new BackLinkVM {
                Show = true, Url = _config.Value.GFCUrls.StartPage, Text = _config.Value.SiteTextStrings.BackLinkText
            };

            //Make Sure we have a clean session
            _sessionService.ClearSession();

            if (!ModelState.IsValid)
            {
                ViewBag.title = $"Error: Find a service" + _config.Value.SiteTextStrings.SiteTitleSuffix;
                return(View(vm));
            }


            var cleanSearch = _gdsValidate.CleanText(vm.SearchTerm, true, restrictedWords, allowedChars);

            if (string.IsNullOrEmpty(cleanSearch))
            {
                ModelState.AddModelError("SearchTerm", _config.Value.SiteTextStrings.EmptySearchError);
                ModelState.SetModelValue("SearchTerm", null, string.Empty);
                return(View(vm));
            }

            return(RedirectToAction(nameof(SearchResults), new { search = cleanSearch }));
        }
示例#10
0
        public IActionResult SearchProducts(SearchVm search)
        {
            var productList = _productService.SearchProduct(search.Id, search.Query);

            return(productList == null
                ? StatusCode(500)
                : (IActionResult)Ok(productList));
        }
 public static bool ShouldRedirect(this SearchVm vm, List <ListingType> listingTypes)
 {
     if (vm.Seo != null)
     {
         return(ShouldRedirect(vm.Seo.CanonicalUrl, listingTypes));
     }
     return(false);
 }
 public static bool ShouldRedirect(this SearchVm vm)
 {
     if (vm.Seo != null)
     {
         return(ShouldRedirect(vm.Seo.CanonicalUrl));
     }
     return(false);
 }
示例#13
0
        public IActionResult SearchCustomers(SearchVm search)
        {
            var customersList = _customerService.SearchCustomer(search.Id, search.Query);

            return(customersList == null
                ? StatusCode(500)
                : (IActionResult)Ok(customersList));
        }
        public IActionResult Search(SearchVm ob)
        {
            Facility_Reservation FR = new Facility_Reservation();
            var Nameexist           = _asu.Patients.ToList().Any(f => f.Name == ob.patientName);

            if (Nameexist)
            {
                var ID         = _asu.Patients.Where(f => f.Name == ob.patientName).Select(s => s.Id).Single();
                var NamePexist = _asu.Facility_Reservations.ToList().Any(f => f.Patient_Id == ID);
                if (NamePexist)
                {
                    /*
                     *              var Startavailable = _asu.Facility_Reservations.Where(f => f.Patient_Id == ID)
                     *                  .Select(s => s.Start_Hour).Single();
                     *              var Endavailable = _asu.Facility_Reservations.Where(f => f.Patient_Id == ID)
                     *                .Select(s => s.End_Hour).Single();
                     *
                     * var Endavailable = _asu.Facility_Reservations.Where(f => f.Patient_Id == ID)
                     *              .Select(s =>new { s.End_Hour ,s.Start_Hour}).ToList();
                     * DateTime parse1 = DateTime.Parse(Startavailable);
                     * DateTime parse2 = DateTime.Parse(Endavailable);
                     */
                    var Endavailable = _asu.Facility_Reservations.Where(f => f.Patient_Id == ID)
                                       .Select(s => new { dates = s.Start_Hour, dateE = s.End_Hour, name = s.Id })
                                       .OrderByDescending(w => w.dateE).FirstOrDefault();
                    //.ToList();
                    //foreach (var V in Endavailable)
                    //{
                    DateTime parse3 = DateTime.Parse(Endavailable.dates);
                    DateTime parse4 = DateTime.Parse(Endavailable.dateE);
                    //int i = V.name;
                    if ((parse3 <= ob.Today && ob.Today <= parse4))
                    {
                        var roomnumber = _asu.Facility_Reservations
                                         .Where(F => F.Id == Endavailable.name)
                                         .Select(s => s.Hospital_Facility_Id).Single();
                        TempData["room"] = _asu.Hospital_Facilities.Where(t => t.Id == roomnumber)
                                           .Select(S => S.Type).Single();
                        ViewBag.DD = TempData["room"];
                        return(View());
                        // return Redirect("/Front_desk/Searchresult");
                    }
                    else
                    {
                        ViewBag.Not = "This patient is not in our hospital.";
                        return(View());
                        //return Redirect("/Front_desk/NotAvailable");
                    }
                    //}
                }
                ViewBag.Not = "This patient is not in our hospital.";
                return(View());
                //return Redirect("/Front_desk/NotAvailable");
            }
            ViewBag.Not = "This patient is not in our hospital.";
            return(View());
            //return Redirect("/Front_desk/NotAvailable");
        }
示例#15
0
        List <Hospital> SearchHospitals(SearchVm searchVm)
        {
            var hospitals = db.Hospitals
                            .Where(c => (c.ContactName.ToLower().Contains(searchVm.SearchTxt.ToLower()) ||
                                         c.Location.ToLower().Contains(searchVm.Location.ToLower())) &&
                                   c.IsApproved);

            return(hospitals.ToList());
        }
示例#16
0
        List <Center> SearchCenters(SearchVm searchVm)
        {
            var centers = db.Centers.Include(c => c.Type)
                          .Where(c => (c.Name.ToLower().Contains(searchVm.SearchTxt.ToLower()) ||
                                       c.Type.Name.ToLower().Contains(searchVm.SearchTxt.ToLower()) ||
                                       searchVm.Location.ToLower().Contains(c.City.ToLower())) && c.IsApproved);

            return(centers.ToList());
        }
示例#17
0
        List <Doctor> SearchDoctors(SearchVm searchVm)
        {
            var doctors = db.Doctors.Include(d => d.Speciality)
                          .Where(d => (d.Name.ToLower().Contains(searchVm.SearchTxt.ToLower()) ||
                                       d.Speciality.Select(c => c.Name.ToLower()).Contains(searchVm.SearchTxt.ToLower()) ||
                                       searchVm.Location.ToLower().Contains(d.City.ToLower())) && d.IsApproved);

            return(doctors.ToList());
        }
        internal static SearchBarVm GetSearchBarVm(SearchVm searchVm)
        {
            SearchBarVm searchBarVm = FillSearchTemplates(FillSearchTypeList(new SearchBarVm
            {
                SearchType = searchVm.Criteria.SearchType()
            }, searchVm));

            searchBarVm.LookupLocation = GetLookupLocation(searchVm.Criteria);
            return(searchBarVm);
        }
示例#19
0
        /// <summary>
        /// Method for obtaining the history of stat. units
        /// </summary>
        /// <param name = "type"> Type of stat. Edinet </param>
        /// <param name = "id"> Id stat. Edinet </param>
        /// <returns> </returns>
        public async Task <object> ShowHistoryAsync(StatUnitTypes type, int id)
        {
            var history = type == StatUnitTypes.EnterpriseGroup
                ? await FetchUnitHistoryAsync <EnterpriseGroup, EnterpriseGroupHistory>(id)
                : await FetchUnitHistoryAsync <StatisticalUnit, StatisticalUnitHistory>(id);

            var result = history.ToArray();

            return(SearchVm.Create(result, result.Length));
        }
示例#20
0
        /// <summary>
        /// Method for obtaining a detailed history of stat. units
        /// </summary>
        /// <param name = "type"> Type of stat. units </param>
        /// <param name = "id"> Id stat. units </param>
        /// <param name = "userId"> User Id </param>
        /// <param name = "isHistory"> Is the stat. historical unit </param>
        /// <returns> </returns>
        public async Task <object> ShowHistoryDetailsAsync(StatUnitTypes type, int id, string userId, bool isHistory)
        {
            var history = type == StatUnitTypes.EnterpriseGroup
                ? await FetchDetailedUnitHistoryAsync <EnterpriseGroup, EnterpriseGroupHistory>(id, userId, isHistory)
                : await FetchDetailedUnitHistoryAsync <StatisticalUnit, StatisticalUnitHistory>(id, userId, isHistory);

            var result = history.ToArray();

            return(SearchVm.Create(result, result.Length));
        }
示例#21
0
        List <Donor> SearchDonors(SearchVm searchVm)
        {
            var donors = db.Donors
                         .Where(c => (c.Name.ToLower().Contains(searchVm.SearchTxt.ToLower()) ||
                                      c.Type.ToLower().Contains(searchVm.SearchTxt.ToLower()) ||
                                      c.Location.ToLower().Contains(searchVm.Location.ToLower())) &&
                                c.IsApproved);

            return(donors.ToList());
        }
示例#22
0
        protected override void BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor)
        {
            SearchVm searchVm = bindingContext.Model as SearchVm;

            base.BindProperty(controllerContext, bindingContext, propertyDescriptor);
            if (searchVm != null)
            {
                BindSearchModel(searchVm, controllerContext, bindingContext, propertyDescriptor);
            }
        }
        public static SearchVm GetStaticContent(PageType type)
        {
            SearchVm obj = new SearchVm
            {
                PageType = type,
                Seo      = SeoHelper.GetSeo(type),
                Criteria = GetInitSearchCriteriaVm()
            };

            obj.Breadcrumbs = GetBreadcrumbs(obj);
            return(obj);
        }
示例#24
0
        public static SeoVm GetSeo(SearchVm result)
        {
            SeoVm seoVm = new SeoVm()
            {
                PageType     = result.PageType,
                CanonicalUrl = MslcUrlBuilder.SearchUrl(result.Criteria, result.PageType.ToSearchType())
            };
            PageType pageType = seoVm.PageType;

            if (pageType <= PageType.ShcByType)
            {
                if (pageType == PageType.Index)
                {
                    seoVm.Title        = Title.Index;
                    seoVm.Header       = Header.Index;
                    seoVm.Description  = Description.Index;
                    seoVm.CanonicalUrl = MslcUrlBuilder.BaseUrl;
                }
                else if (pageType == PageType.ShcByType)
                {
                    seoVm.Title       = Title.SearchSHC;
                    seoVm.Description = Description.SearchSHC;
                    seoVm.Header      = Header.SearchSHC;
                    seoVm.MarketCopy  = MarketCopy.SearchSHC;
                }
            }
            else if (pageType == PageType.AacByType)
            {
                seoVm.Title       = Title.SearchAAC;
                seoVm.Description = Description.SearchAAC;
                seoVm.Header      = Header.SearchAAC;
                seoVm.MarketCopy  = MarketCopy.SearchAAC;
            }
            else if (pageType == PageType.AahByType)
            {
                seoVm.Title       = Title.SearchAAH;
                seoVm.Description = Description.SearchAAH;
                seoVm.Header      = Header.SearchAAH;
                seoVm.MarketCopy  = MarketCopy.SearchAAH;
            }
            else if (pageType == PageType.ServiceProvidersByType)
            {
                seoVm.Title       = Title.SearchServices;
                seoVm.Description = Description.SearchServices;
                seoVm.Header      = Header.SearchServices;
                seoVm.MarketCopy  = MarketCopy.SearchServices;
            }
            seoVm.Title       = seoVm.Title.Replace(result);
            seoVm.Description = seoVm.Description.Replace(result);
            seoVm.Header      = seoVm.Header.Replace(result);
            return(seoVm);
        }
示例#25
0
        /// <summary>
        /// Stat search method. units
        /// </summary>
        /// <param name = "filter"> Request </param>
        /// <param name = "userId"> User Id </param>
        /// <param name = "isDeleted"> Distance flag </param>
        /// <returns> </returns>
        public async Task <SearchVm> Search(SearchQueryM filter, string userId, bool isDeleted = false)
        {
            await _elasticService.CheckElasticSearchConnection();

            bool isAdmin = await _userService.IsInRoleAsync(userId, DefaultRoleNames.Administrator);

            long totalCount;
            List <ElasticStatUnit> units;

            if (filter.IsEmpty())
            {
                var baseQuery = _dbContext.StatUnitSearchView
                                .Where(s => s.IsDeleted == isDeleted && s.LiqDate == null);

                totalCount = baseQuery.Count();
                units      = (await baseQuery.Skip((filter.Page - 1) * filter.PageSize).Take(filter.PageSize).ToListAsync())
                             .Select(Mapper.Map <StatUnitSearchView, ElasticStatUnit>).ToList();
            }
            else
            {
                var searchResponse = await _elasticService.Search(filter, userId, isDeleted);

                totalCount = searchResponse.TotalCount;
                units      = searchResponse.Result.ToList();
            }

            var finalIds = units.Where(x => x.UnitType != StatUnitTypes.EnterpriseGroup)
                           .Select(x => x.RegId).ToList();
            var finalRegionIds = units.Select(x => x.RegionId).ToList();

            var unitsToPersonNames = await GetUnitsToPersonNamesByUnitIds(finalIds);

            var unitsToMainActivities = await GetUnitsToPrimaryActivities(finalIds);

            var regions = await GetRegionsFullPaths(finalRegionIds);

            var permissions = await _userService.GetDataAccessAttributes(userId, null);

            var helper = new StatUnitCheckPermissionsHelper(_dbContext);
            var result = units
                         .Select(x => new SearchViewAdapterModel(x, unitsToPersonNames[x.RegId],
                                                                 unitsToMainActivities[x.RegId],
                                                                 regions.GetValueOrDefault(x.RegionId)))
                         .Select(x => SearchItemVm.Create(x, x.UnitType,
                                                          permissions.GetReadablePropNames(),
                                                          !isAdmin && !helper.IsRegionOrActivityContains(userId, x.RegionId != null ? new List <int> {
                (int)x.RegionId
            } : new List <int>(), x.ActivityCategoryIds)));

            return(SearchVm.Create(result, totalCount));
        }
示例#26
0
        public ActionResult Search(SearchVm searchVm)
        {
            var searchTransportData = _db.Transports.AsQueryable();



            if (!string.IsNullOrEmpty(searchVm.From))
            {
                searchTransportData = searchTransportData.Where(c => c.From.Contains(searchVm.From));
            }



            if (searchVm.Date != null)
            {
                DateTime date = (DateTime)searchVm.Date;
                searchTransportData = searchTransportData.Where(c => c.DateTime.Date == date.Date);
            }

            if (searchVm.BudgetFrom > 0)
            {
                searchTransportData = searchTransportData.Where(c => c.Price >= searchVm.BudgetFrom);
            }

            if (searchVm.BudgetTo > 0)
            {
                searchTransportData = searchTransportData.Where(c => c.Price <= searchVm.BudgetTo);
            }


            searchVm.Transports = searchTransportData.ToList();

            var searchHotelData = _db.Hotels.AsQueryable();

            if (!string.IsNullOrEmpty(searchVm.To))
            {
                searchHotelData = searchHotelData.Where(c => c.Location.Contains(searchVm.To));
            }
            if (searchVm.BudgetFrom > 0)
            {
                searchHotelData = searchHotelData.Where(c => c.Price >= searchVm.BudgetFrom);
            }

            if (searchVm.BudgetTo > 0)
            {
                searchHotelData = searchHotelData.Where(c => c.Price <= searchVm.BudgetTo);
            }
            searchVm.Hotels = searchHotelData.ToList();
            return(View(searchVm));
        }
示例#27
0
        public async Task <SearchVm <QueueVm> > GetAllDataSourceQueues(SearchQueryM query)
        {
            var sortBy = string.IsNullOrEmpty(query.SortBy)
                ? "Id"
                : query.SortBy;

            var orderRule = query.OrderByValue == OrderRule.Asc && !string.IsNullOrEmpty(query.SortBy)
                ? "ASC"
                : "DESC";

            var filtered = _dbContext.DataSourceQueues
                           .Include(x => x.DataSource)
                           .Include(x => x.User)
                           .AsNoTracking();

            if (query.Status.HasValue)
            {
                filtered = filtered.Where(x => x.Status == query.Status.Value);
            }

            if (query.DateFrom.HasValue && query.DateTo.HasValue)
            {
                filtered = filtered.Where(x => x.StartImportDate >= query.DateFrom.Value &&
                                          x.StartImportDate <= query.DateTo.Value);
            }
            else
            {
                if (query.DateFrom.HasValue)
                {
                    filtered = filtered.Where(x => x.StartImportDate >= query.DateFrom.Value);
                }

                if (query.DateTo.HasValue)
                {
                    filtered = filtered.Where(x => x.StartImportDate <= query.DateTo.Value);
                }
            }

            filtered = filtered.OrderBy($"{sortBy} {orderRule}");

            var total = await filtered.CountAsync();

            var result = await filtered
                         .Skip(Pagination.CalculateSkip(query.PageSize, query.Page, total))
                         .Take(query.PageSize)
                         .AsNoTracking()
                         .ToListAsync();

            return(SearchVm <QueueVm> .Create(result.Select(QueueVm.Create), total));
        }
示例#28
0
        public void SearchVmFromModel()
        {
            var category = new DomainModel.Core.Donation.Category {
                Id = 0, Name = "TestCategory"
            };
            var subcategory = new DomainModel.Core.Donation.SubCategory {
                Id = 0, Name = "TestSubCategory", Category = category
            };
            var searchFromModel = SearchVm.FromModel(new Search {
                Category = category, ZipCode = 55403, SubCategory = subcategory
            });

            Assert.AreEqual(searchFromModel.ZipCode, 55403);
            Assert.AreEqual(searchFromModel.Category.Name, "TestCategory");
        }
        public List <Accommodation> QuickSearch(SearchVm sm)
        {
            List <Accommodation> result = new List <Accommodation>();

            if (!string.IsNullOrEmpty(sm.Search))
            {
                sm.Search = CustomFormat(sm.Search);
            }

            string sql =
                "SELECT [AccommodationId], [Title], [Description], [Image], " +
                "[Country] FROM [Accommodation]";

            List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >();


            if (sm.Country != null)
            {
                sql += "WHERE [Country] = @country";
                parameters.Add(new KeyValuePair <string, string>("@country", Convert.ToInt32(sm.Country).ToString()));
            }


            DataSet results = ExecuteSql(sql, parameters);

            for (int x = 0; x < results.Tables[0].Rows.Count; x++)
            {
                Accommodation a = DataSetParser.DataSetToAccommodation(results, x);
                result.Add(GetPrices(a));
            }

            if (sm.TravelType == TravelTypes.Zomer)
            {
                result = result.Where(n => n.DatePrices.Count(m => m.Date.Month >= 3 || m.Date.Month <= 9) != 0).ToList();
            }
            else if (sm.TravelType == TravelTypes.Winter)
            {
                result = result.Where(n => n.DatePrices.Count(m => m.Date.Month <= 2 || m.Date.Month >= 10) != 0)
                         .ToList();
            }

            if (sm.Month != null)
            {
                result = result.Where(n => n.DatePrices.Count(m => m.Date.Month == (int)(Months)sm.Month + 1) != 0).ToList();
            }

            return(result);
        }
示例#30
0
        public IActionResult Index()
        {
            //Make Sure we have a clean session
            _sessionService.ClearSession();

            _sessionService.SetLastPage("search/find-a-service");

            ViewBag.BackLink = new BackLinkVM {
                Show = true, Url = _config.Value.GFCUrls.StartPage, Text = _config.Value.SiteTextStrings.BackLinkText
            };

            ViewBag.title = "Find a service" + _config.Value.SiteTextStrings.SiteTitleSuffix;
            var vm = new SearchVm();

            return(View(vm));
        }