Esempio n. 1
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["add_new_car.cshtml"]);
            };
// ==============================================================
            Get["/view_all_cars"] = _ => {
                // List<Car> _instances = Car.GetAll();
                List <Car> allCars = Car.GetAll();
                return(View["view_all_cars.cshtml", allCars]);
            };
// ==============================================================
            Post["/added"] = _ => {
                string MakeModel = (Request.Form["MakeModel"]);
                int    Price     = (Request.Form["Price"]);
                int    Miles     = (Request.Form["Miles"]);
                Car    newCar    = new Car(MakeModel, Price, Miles);
                newCar.Save();
                return(View["car_added.cshtml", newCar]);
            };

            Post["/cars_cleared"] = _ => {
                Car.ClearAll();
                return(View["cars_cleared.cshtml"]);
            };
        }
Esempio n. 2
0
        public HomeModule()
        {
            Get["/"] = _ => View["buy_sell_cars.cshtml"];

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

            Post["/add_your_car"] = _ => {
                Car newCar = new Car(Request.Form["new-car-model"], Request.Form["new-car-year"], Request.Form["new-car-mileage"]);
                newCar.AddToList();
                return(View["car_added.cshtml", newCar]);
            };
        }
Esempio n. 3
0
        public HomeModule()
        {
            Dictionary <string, object> Inventory = new Dictionary <string, object>();

            Get["/"] = _ => {
                List <Car> currentInventory = Car.GetAll();
                foreach (var car in currentInventory)
                {
                    Console.WriteLine(car.GetMakeModel());
                }
                Inventory.Add("CarInventory", currentInventory);
                return(View["car_index.cshtml", Inventory]);
            };
            Get["/add_car"]    = _ => View["add_car.cshtml"];
            Post["/car_added"] = _ =>
            {
                Car newCar = new Car(Request.Form["make-model"], Request.Form["price"], Request.Form["miles"], Request.Form["description"]);
                return(View["car_added.cshtml", newCar]);
            };
        }
Esempio n. 4
0
 public HomeModule()
 {
     Get["/"] = _ => {
         Program.Main();
         return(View["form.cshtml"]);
     };
     Post["/car"] = _ => {
         int        maxPrice   = int.Parse(Request.Form["maxPrice"]);
         int        maxMiles   = int.Parse(Request.Form["maxMiles"]);
         List <Car> returnCars = new List <Car> {
         };
         List <Car> allCars    = Car.GetAll();
         foreach (Car automobile in allCars)
         {
             if (automobile.WorthBuying(maxPrice, maxMiles))
             {
                 returnCars.Add(automobile);
             }
         }
         return(View["car.cshtml", returnCars]);
     };
 }
Esempio n. 5
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["/cars_cleared"] = _ => {
                Car.ClearAll();
                return(View["cars_cleared.cshtml"]);
            };

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