Exemple #1
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Get["/lot"] = _ => {
         List <Car> allCars = Car.GetAll();
         return(View["lot.cshtml", allCars]);
     };
     Get["/car/new"] = _ => {
         return(View["sell_form.cshtml"]);
     };
     Get["/cars/{id}"] = parameters => {
         Car car = Car.Find(parameters.id);
         return(View["car.cshtml", car]);
     };
     Post["/sellCar"] = _ => {
         Car        newCar  = new Car(Request.Form["new-make"], Request.Form["new-model"], Request.Form["new-year"], Request.Form["new-miles"], Request.Form["new-description"]);
         List <Car> allCars = Car.GetAll();
         return(View["lot.cshtml", allCars]);
     };
     Post["/buy"] = _ => {
         int _id = Request.Form["id"];
         Car.BuyCar(_id);
         List <Car> allCars = Car.GetAll();
         return(View["lot.cshtml", allCars]);
     };
 }
Exemple #2
0
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Car> allCars = Car.GetAll();
         return(View["view_all_cars.cshtml", allCars]);
     };
     Get["/add_car"] = _ => {
         return(View["add_car.cshtml"]);
     };
     Post["/"] = _ => {
         Car newCar = new Car(Request.Form["make-model"], Request.Form["color"], Request.Form["miles"], Request.Form["price"]);
         Vehicle.SaveToDict(newCar);
         // Vehicle.Store(newCar);
         return(View["add_car.cshtml"]);
     };
     Get["/car_values"] = _ => {
         Dictionary <string, object> carDictionary = Vehicle.GetDictionary();
         return(View["view_car_types.cshtml", carDictionary]);
     };
     Get["/car_search"] = _ => {
         Car carResult = Car.Search(Request.Query["search-id"]);
         return(View["car_search_results.cshtml", carResult]);
     };
     Get["/cars/{id}"] = parameters => {
         Car car = Car.Search(parameters.id);
         return(View["/car.cshtml", car]);
     };
     Post["/cars/{id}"] = parameters => {
         Car car = Car.Search(parameters.id);
         car.Remove();
         List <Car> allCars = Car.GetAll();
         return(View["view_all_cars.cshtml", allCars]);
     };
 }
Exemple #3
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"];
            // };
        }
Exemple #4
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"]);
     };
 }
 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]);
     };
 }
        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];
            // };
        }
        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"]);
            };
        }