コード例 #1
0
        public IEnumerable<RouteViewModel> GetUserId([FromUri]RouteSearchParametersViewModel search)
        {
            var searchParameters = new RouteSearchParameters();
            searchParameters.AuthorId = this.UserId;
            
            var orderByField = RouteSortOptions.AllRoutes;
            if (Enum.TryParse<RouteSortOptions>(search.OrderByFieldName, true, out orderByField))
            {
                searchParameters.SortOrder = orderByField;
            }


            searchParameters.PageNumber = 0;
            searchParameters.PageSize = 5000;
            IEnumerable<RouteData> routes = routeService.Search(searchParameters).ToArray();

            var routesModels = routes.Select(RouteViewModel.MapToSearchViewModel).ToList();
            return routesModels;
        }
コード例 #2
0
        public IEnumerable<RouteViewModel> GetRoutes([FromUri]RouteSearchParametersViewModel search)
        {
            var searchParameters = new RouteSearchParameters();
            searchParameters.MeetingPlace = search.Location;

            //TODO: Refactor the code below. Do not parse values replace types in RouteSearchParametersViewModel class
            DateTime dateFrom;
            if (DateTime.TryParse(search.DateFrom, out dateFrom))
            {
                searchParameters.DateFrom = dateFrom;
            }

            DateTime dateTo;
            if (DateTime.TryParse(search.DateTo, out dateTo))
            {
                searchParameters.DateTo = dateTo;
            }

            double minDistance = 0;
            if (double.TryParse(search.MinDistance, out minDistance))
            {
                searchParameters.MinDistance = minDistance;
            }

            double maxDistance = 0;
            if (double.TryParse(search.MaxDistance, out maxDistance))
            {
                searchParameters.MaxDistance = maxDistance;
            }
           
            var orderByField = RouteSortOptions.Date;

            if (Enum.TryParse<RouteSortOptions>(search.OrderByFieldName, true, out orderByField))
            {
                searchParameters.SortOrder = orderByField;
            }

            searchParameters.SearchType = search.SearchType ?? String.Empty;
            searchParameters.AuthorId = UserId;
            searchParameters.PageNumber = search.PageNumber;
            searchParameters.PageSize = 5000;
            IEnumerable<RouteData> routes = routeService.Search(searchParameters).ToArray();

            var routesModels = routes.Select(RouteViewModel.MapToSearchViewModel).ToList();
            return routesModels;
        }
コード例 #3
0
ファイル: RouteService.cs プロジェクト: BikeMates/bike-mates
 public IEnumerable<RouteData> Search(RouteSearchParameters searchParameters)
 {
     return this.routeRepository.Search(searchParameters).ToList().Select(MapRoute);
 }