//# Function to list of cars that are eligible for users request
        public List<Car> GetCars(InputRequestAttributes RequestQuery)
        {
            //# Get the list of zipcodes that are located in specified distance from user requested zipcode
            ConnectedRepository ctx = new ConnectedRepository(DbName);
            LocationDataLayer lctx = new LocationDataLayer();
            List<string> NearByZipCodes = new List<string>();
            if (!string.IsNullOrEmpty(RequestQuery.Zipcode))
            {
                List<Location> locationsAround = lctx.GetNearZipcodes(RequestQuery.Zipcode,RequestQuery.distance);
                if (locationsAround.Count != 0)
                {
                    foreach (Location location in locationsAround)
                    {
                        NearByZipCodes.Add(location.zip);
                    }
                    NearByZipCodes.Add(RequestQuery.Zipcode);
                }
            }
            //# Build a DB query based on user constraint. Check request if it has value and add it to query.
            QueryDocument CarQuery = new QueryDocument();

            if (RequestQuery.Year > 2000)
                CarQuery.Add("Year", RequestQuery.Year);
            if (RequestQuery.Name != null)
                CarQuery.Add("Name", RequestQuery.Name);
            if (RequestQuery.Maker != null)
                CarQuery.Add("Maker", RequestQuery.Maker);
            if (RequestQuery.MaxPrice >= 1000)
                CarQuery.Add("Price", new BsonDocument("$lt", RequestQuery.MaxPrice));
            if (NearByZipCodes.Count() != 0)
                CarQuery.Add("Zipcode", new BsonDocument("$in", new BsonArray(NearByZipCodes)));
            MongoCursor<Car> Cars = ctx.Cars.Find(CarQuery);
            List<Car> carsList = Cars.ToList();
            return carsList;
        }
        public ActionResult Cars(string id, string name, string maker,string sortOrder,int price = 0,int distance = 50, int year = 0, string zipcode = "19333")
        {
            InputRequestAttributes Carreq = new InputRequestAttributes();
            Manager manager = new Manager();

            // prepare the request object to send it to DAL. So DAL checks for the constraints that present in the Car object
            // and prepares the dynamic DB query.

             Carreq.Zipcode = zipcode;
            if(maker!="All")
             Carreq.Maker = maker;
            if(name!="All")
             Carreq.Name = name;
            Carreq.MaxPrice = price;
            Carreq.Year = year;
            Carreq.distance = distance;
            List<Car> carsList = _carsdata.GetCars(Carreq);
            List<Car> SortedList = manager.SortCars(sortOrder,carsList);
            return View(SortedList);
        }