//
        // GET: /Booking/Create
        public ActionResult Create(string car_reg, string place, int from_year, int from_month, int from_day,
             int to_year, int to_month, int to_day)
        {
            var email = "";
             if (User.Identity.IsAuthenticated)
                  email = Membership.GetUser().Email;
             UserObj u = CustomUserService.loadUser(email);
             if (!u.Customer)
             {
                  return RedirectToAction("Login", "Account", new
                  {
                       returnUrl = "/Booking/Create?car_reg=" + car_reg +
                       "&from_year=" + from_year + "&from_month=" + from_month + "&from_day=" +
                       from_day + "&to_year=" + to_year + "&to_month=" + to_month +  "&to_day=" +
                       to_day + "&place=" + place
                  });
             }
             var from_string = from_year + "/" + from_month + "/" + from_day;
             DateTime fromdate = DateTime.ParseExact(from_string, "yyyy/M/d", null);
             var to_string = to_year + "/" + to_month + "/" + to_day;
             DateTime todate = DateTime.ParseExact(to_string, "yyyy/M/d", null);

            BookingCreateUI showChosenCar = new BookingCreateUI();
            Car car = new Car();
            car.car_reg = car_reg;
            showChosenCar.fromDate = fromdate;
            showChosenCar.toDate = todate;
            showChosenCar.car = car;
            showChosenCar.place = place;

            BookingCreateUI result = logic.ShowChosenCar(showChosenCar);
            return View(result);
        }
Exemplo n.º 2
0
        List<Car> IDataparser.parseCars()
        {
            List<Car> ret = new List<Car>();
               CsvReader csv = new CsvReader(reader, true);
               int fieldCount = csv.FieldCount;

               String[] headers = csv.GetFieldHeaders();

               while (csv.ReadNextRecord())
               {
                    Car carObj = new Car();

                    for (int i = 0; i < fieldCount; i++)
                    {
                         if (headers[i].Equals("car_reg"))
                         {
                              carObj.car_reg= csv[i];
                         }
                         else if (headers[i].Equals("cost_per_day"))
                         {
                              carObj.cost_per_day = Convert.ToDecimal(csv[i]);
                         }
                         else if (headers[i].Equals("location"))
                         {
                              carObj.location = csv[i];

                         }
                         else if (headers[i].Equals("car_make"))
                         {
                              carObj.car_make= csv[i];

                         }
                         else if (headers[i].Equals("car_model"))
                         {
                              carObj.car_model = csv[i];

                         }
                         else if (headers[i].Equals("number_of_passengers"))
                         {
                              carObj.number_of_passengers = Convert.ToInt32(csv[i]);

                         }
                         else if (headers[i].Equals("luggage_space"))
                         {
                              carObj.luggage_space = csv[i];

                         }
                         else if (headers[i].Equals("image_url"))
                         {
                              carObj.image_url = csv[i];

                         }
                         ret.Add(carObj);
                    }
               }

               return ret;
        }