コード例 #1
0
        public HomeModule()
        {
            Get["/"]= _ => View["addCar.cshtml"];
            //make view all cars cshtml file so we can be sent there
            Get["/view_all_cars"] = _ => {
              List<Car> allCars = Car.GetAll();
              return View["view_all_cars.cshtml", allCars];
              };
              Post["/cars_added"]= _ => {
            Car newCar = new Car (Request.Form["Make_model"],Request.Form["Price"], Request.Form["Mileage"]);
            newCar.Save(newCar);
            return View["cars_added.cshtml", newCar];
              };
              Post["/cars_cleared"]= _ => {
            Car.ClearAll();
            return View["cars_cleared.cshtml"];
              };
              Post["/car_search"]= _ => {
            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 auto in allCars)
            {
              if (auto.WorthBuying(maxPrice, maxMiles))
              {
                returnCars.Add(auto);
              }

            }
            return View["car_search.cshtml", returnCars];
              };
        }
コード例 #2
0
ファイル: HomeModules.cs プロジェクト: aml630/carlist-csharp
 public HomeModule()
 {
     Get["/"]= _ => View["addCar.cshtml"];
     //make view all cars cshtml file so we can be sent there
     Get["/view_all_cars"] = _ => {
       List<Car> allCars = Car.GetAll();
       return View["view_all_cars.cshtml", allCars];
       };
       Post["/cars_added"]= _ => {
     Car newCar = new Car (Request.Form["Make_model"],Request.Form["Price"], Request.Form["Mileage"]);
     newCar.Save(newCar);
     return View["cars_added.cshtml", newCar];
       };
       Post["/cars_cleared"]= _ => {
     Car.ClearAll();
     return View["cars_cleared.cshtml"];
       };
 }