Exemple #1
0
        public void Execute()
        {
            var apple   = new Product("Apple", Color.Green, Size.Small);
            var ball    = new Product("Ball", Color.Green, Size.Small);
            var tree    = new Product("Tree", Color.Green, Size.Large);
            var cooperS = new Product("Mini-Cooper S", Color.Red, Size.Large);

            Product[] products    = { apple, tree, cooperS, ball };
            var       filterItems = new FilterItems();

            Console.WriteLine("Green products:");
            foreach (var product in filterItems.Filter(products, new ColorSpecification(Color.Green)))
            {
                Console.WriteLine($" - {product.Name} is green");
            }

            Console.WriteLine();

            Console.WriteLine("Green and small products");
            foreach (var product in filterItems.Filter(products,
                                                       new GreenAndSmallSpecification(
                                                           new ColorSpecification(Color.Green),
                                                           new SizeSpecification(Size.Small))))
            {
                Console.WriteLine($" - {product.Name} is green and small");
            }

            Console.WriteLine();

            Console.WriteLine("Green cars");
            var carFilter   = new FilterCars();
            var bentley     = new Car("Bentley", Color.Green);
            var shevyCamaro = new Car("Shevy Camaro", Color.Green);
            var astonMartin = new Car("Aston Martin", Color.Black);

            Car[] cars = { bentley, shevyCamaro, astonMartin };

            foreach (var car in carFilter.Filter(cars, new CarColorSpecification(Color.Green)))
            {
                Console.WriteLine($" - {car.Name} is a green car");
            }

            Console.ReadLine();
        }
    public List <CarsInfo.UsedCarsInfo> GetCarsFilterMobile(string carMakeID, string CarModalId,
                                                            string Mileage, string Year, string Price, string Sort, string Orderby, string pageSize, string CurrentPage, string Zipcode, string AuthenticationID, string CustomerID)
    {
        CarsFilter objCarsFilter = new CarsFilter();


        Filter objFilter = new Filter();

        List <CarsInfo.UsedCarsInfo> objFilterdata = new List <CarsInfo.UsedCarsInfo>();


        CarsInfo.UsedCarsInfo OBJ = new CarsInfo.UsedCarsInfo();



        string sort = string.Empty;

        objCarsFilter.CurrentPage = CurrentPage;
        objCarsFilter.PageSize    = pageSize;
        objCarsFilter.CarMakeid   = carMakeID;
        objCarsFilter.CarModalId  = CarModalId;
        objCarsFilter.Sort        = Sort;
        objCarsFilter.Orderby     = Orderby;
        objCarsFilter.ZipCode     = Zipcode;



        objCarsFilter.Sort = sort;



        switch (Mileage)
        {
        case "Mileage1":
            objCarsFilter.Mileage1 = "Mileage1";
            break;

        case "Mileage2":
            objCarsFilter.Mileage2 = "Mileage2";
            break;

        case "Mileage3":
            objCarsFilter.Mileage3 = "Mileage3";
            break;

        case "Mileage4":
            objCarsFilter.Mileage4 = "Mileage4";
            break;

        case "Mileage5":
            objCarsFilter.Mileage5 = "Mileage5";
            break;

        case "Mileage6":
            objCarsFilter.Mileage6 = "Mileage6";
            break;

        case "Mileage7":
            objCarsFilter.Mileage7 = "Mileage7";
            break;
        }
        switch (Year)
        {
        case "Year1a":
            objCarsFilter.Year1a = "Year1a";
            break;

        case "Year1b":
            objCarsFilter.Year1b = "Year1b";
            break;

        case "Year1":
            objCarsFilter.Year1 = "Year1";
            break;

        case "Year2":
            objCarsFilter.Year2 = "Year2";
            break;

        case "Year3":
            objCarsFilter.Year3 = "Year3";
            break;

        case "Year4":
            objCarsFilter.Year4 = "Year4";
            break;

        case "Year5":
            objCarsFilter.Year5 = "Year5";
            break;

        case "Year6":
            objCarsFilter.Year6 = "Year6";
            break;

        case "Year7":
            objCarsFilter.Year7 = "Year7";
            break;
        }
        switch (Price)
        {
        case "Price1":
            objCarsFilter.Price1 = "Price1";
            break;

        case "Price2":
            objCarsFilter.Price2 = "Price2";
            break;

        case "Price3":
            objCarsFilter.Price3 = "Price3";
            break;

        case "Price4":
            objCarsFilter.Price4 = "Price4";
            break;

        case "Price5":
            objCarsFilter.Price5 = "Price5";
            break;
        }
        ;


        FilterCars objFilterCars = new FilterCars();
        MobileBL   objMobileBL   = new MobileBL();

        if (CustomerID.Trim() != "")
        {
            string  parameter      = carMakeID + "," + CarModalId + "," + Mileage + "," + Year + "," + Price + "," + Sort + "," + Orderby + "," + Zipcode;
            DataSet dsSaveCustInfo = objMobileBL.SaveMobileCustomerInfo("GetCarsFilterMobile", CustomerID, AuthenticationID, parameter);
        }
        if (AuthenticationID == ConfigurationManager.AppSettings["AppleID"].ToString())
        {
            objFilterdata = (List <CarsInfo.UsedCarsInfo>)objFilterCars.FilterSearchMobile(objCarsFilter);
        }
        return(objFilterdata);
    }