public IActionResult Index()
        {
            var location = GeolocationAPIService.GetCurrentLocation();

            var indexModel = new IndexViewModel
            {
                BlogsListViewModel      = this.blogsService.GetAll(3, 0, "CreatedOn", OrderType.Descending),
                CategoriesListViewModel = new CategoriesListViewModel {
                    Categories = this.categoriesService.GetAll <CategoryViewModel>(8, "CreatedOn", OrderType.Descending)
                },
                PostsListViewModel = this.postsService.GetAllPosts(5, 0, "CreatedOn", string.Empty, string.Empty, string.Empty, OrderType.Descending),
                Location           = new LocationViewModel
                {
                    CityName    = location.CityName,
                    CountryName = location.CountryName,
                },
            };

            return(this.View(indexModel));
        }
        public PostsListViewModel GetAllPosts(int count, int skip, string param, string jobConstraints, string location, string categoryName, OrderType orderType)
        {
            var geolocation = GeolocationAPIService.GetCurrentLocation();

            string countryName = string.Empty;
            string cityName    = string.Empty;
            string state       = string.Empty;

            string jobTitle = string.Empty;

            if (string.IsNullOrEmpty(location) || location.ToLower() == "all")
            {
                countryName = geolocation.CountryName;
                cityName    = geolocation.CityName;
                state       = geolocation.State;
            }
            else
            {
                countryName = location.Split(", ")[1];
                cityName    = location.Split(", ")[0];
            }

            if (string.IsNullOrEmpty(cityName))
            {
                cityName = "Sofia";
            }

            var postsQuery = this.postRepository
                             .All();

            var posts = new List <PostViewModel>();

            if (string.IsNullOrEmpty(jobConstraints))
            {
                posts = postsQuery.Where(p => p.Country.Name.ToLower() == countryName.ToLower() &&
                                         p.City.Name.ToLower() == cityName.ToLower())
                        .OrderBy <JobPost>(param, orderType)
                        .Skip(skip)
                        .Take(count)
                        .To <PostViewModel>()
                        .ToList();
            }
            else
            {
                posts = postsQuery.Where(p => p.Country.Name.ToLower() == countryName.ToLower() &&
                                         p.City.Name.ToLower() == cityName.ToLower() &&
                                         p.JobTitle.ToLower() == jobConstraints.ToLower())
                        .OrderBy <JobPost>(param, orderType)
                        .Skip(skip)
                        .Take(count)
                        .To <PostViewModel>()
                        .ToList();
            }

            ;

            return(new PostsListViewModel
            {
                Posts = posts,
            });
        }