Пример #1
0
        public HomeModule()
        {
            Get["/"] = _ => View["add-car.cshtml"];
            Get["/car-collection"] = _ => {
                List <Car> allCars = Car.GetAll();
                return(View["car-collection.cshtml", allCars]);
            };

            Post["/car-added"] = _ => {
                string userMakeModel = Request.Form["make-model"];
                int    userPrice     = Request.Form["price"];
                int    userMiles     = Request.Form["miles"];
                Car    newCar        = new Car(userMakeModel, userPrice, userMiles);
                newCar.Save();
                return(View["car-added.cshtml", newCar]);
            };

            // Post["/car-cleared"] = _ => {
            //   string userMakeModel = Request.Form["make-model"];
            //   int userPrice = Request.Form["price"];
            //   int userMiles = Request.Form["miles"];
            //   Car newCar = new Car(userMakeModel, userPrice, userMiles);
            //   newCar.Remove();
            //   return View["add-car.cshtml"];
            // };
        }
Пример #2
0
 public HomeModule()
 {
     Get["/"] = _ => View["add_new_car.cshtml"];
     Get["/view_all_cars"] = _ => {
         List <Car> allCars = Car.GetAll();
         return(View["view_all_cars.cshtml", allCars]);
     };
     Post["/car_added"] = _ => {
         Car newCar = new Car(Request.Form["new-make-model"], Request.Form["new-price"], Request.Form["new-miles"]);
         newCar.Save();
         return(View["car_added.cshtml", newCar]);
     };
     Post["/cars_cleared"] = _ => {
         Car.ClearAll();
         return(View["cars_cleared.cshtml"]);
     };
 }
Пример #3
0
 public HomeModule()
 {
     Get["/"]             = _ => View["list_form.cshtml"];
     Get["car_inventory"] = _ => {
         List <Car> allCars = Car.GetAll();
         return(View ["car_inventory.cshtml", allCars]);
     };
     Post["/car_inventory"] = _ => {
         Car newCar = new Car
                      (
             Request.Form["new-make"],
             Request.Form["new-model"],
             Request.Form["new-mileage"],
             Request.Form["new-price"]
                      );
         newCar.Save();
         return(View["car_inventory.cshtml", newCar]);
     };
 }
Пример #4
0
        public HomeModule()
        {
            Get["/"] = _ => View["index.cshtml"];

            Get["/add_car_form"] = _ => View["addCar.cshtml"];

            Post["/addCar"] = _ => {
                Car newCar = new Car(
                    Request.Form["carModel"],
                    Request.Form["carMake"],
                    Request.Form["carColor"],
                    Request.Form["carYear"],
                    Request.Form["carMile"],
                    Request.Form["carPrice"]
                    );
                newCar.Save();
                return(View["addCar.cshtml"]);
            };

            Get["/carListing"] = _ => {
                List <Car> allCars = Car.GetAll();
                return(View["carListing.cshtml", allCars]);
            };


            Get["/searchCar"] = _ => {
                return(View["searchCar.cshtml"]);
            };
            // Get["/searchResult"] = _ => {
            //     Car findCar = new Car();
            //     findCar.SetModel(Request.Query["carModel"]);
            //     findCar.SetMake(Request.Query["carMake"]);
            //     findCar.SetColor(Request.Query["carColor"]);
            //     findCar.SetYear(Request.Query["carYear"]);
            //     findCar.SetMiles(Request.Query["carMile"]);
            //     findCar.SetPrice(Request.Query["carPrice"]);
            //     List<Car> matchedCars = Car.searchCars(findCar);
            //     return View["searchResult.cshtml", matchedCars];
            // };
        }
Пример #5
0
        public HomeModule()
        {
            Get["/"]            = _ => View["index.cshtml"];
            Get["/add-new-car"] = _ => View["add_new_car.cshtml"];
            Get["/search-cars"] = _ => View["search_cars.cshtml"];
            Get["/view-all"]    = _ => {
                List <Car> allCars = Car.GetAll();
                return(View["view_all_cars.cshtml", allCars]);
            };
            Post["/view-searched"] = _ => {
                int        searchPrice   = int.Parse(Request.Form["search-price"]);
                int        searchMileage = int.Parse(Request.Form["search-mileage"]);
                List <Car> allCars       = Car.GetAll();
                List <Car> searchedCars  = new List <Car> {
                };

                foreach (Car thing in allCars)
                {
                    if (thing.GetPrice() <= searchPrice && thing.GetMiles() <= searchMileage)
                    {
                        searchedCars.Add(thing);
                    }
                }
                return(View["view_searched_cars.cshtml", searchedCars]);
            };
            Post["/car-added"] = _ => {
                string carMake  = Request.Form["car-make"];
                int    carPrice = int.Parse(Request.Form["car-price"]);
                int    carMiles = int.Parse(Request.Form["car-mileage"]);
                Car    newCar   = new Car(carMake, carPrice, carMiles);
                newCar.Save();
                return(View["car_added.cshtml", newCar]);
            };
            Post["/cars-cleared"] = _ => {
                Car.ClearAll();
                return(View["cars_cleared.cshtml"]);
            };
        }