コード例 #1
0
 public ActionResult Index(DateTime?StartDate, DateTime?EndDate)
 {
     // For the filtering
     if (StartDate != null && EndDate != null)
     {
         var booking = new BookingViewModel()
         {
             bookinglist = _bookingManager.GetAllBooking().Where(s => s.StartBookingDate >= StartDate).Where(s => s.StartBookingDate <= StartDate)
         };
         ViewBag.VehicleId = new SelectList(_vehicleManager.GetAllVehicle(), "VehicleId", "LicencePlate");
         ViewBag.ServiceId = new SelectList(_serviceManager.GetAllService(), "ServiceId", "ServiceName");
         return(View(booking));
     }
     // For the normal listing
     else
     {
         var booking = new BookingViewModel()
         {
             bookinglist = _bookingManager.GetAllBooking()
         };
         ViewBag.VehicleId = new SelectList(_vehicleManager.GetAllVehicle(), "VehicleId", "LicencePlate");
         ViewBag.ServiceId = new SelectList(_serviceManager.GetAllService(), "ServiceId", "ServiceName");
         return(View(booking));
     }
 }
コード例 #2
0
        public ActionResult Index(BookingViewModel booking)
        {
            try
            {
                booking.CustomerId = (int)Session["Id"];
                if (ModelState.IsValid)
                {
                    if (booking.StartBookingDate < DateTime.Now)
                    {
                        throw new Exception("Start Booking date must be greater than today's date");
                    }
                    if (booking.StartBookingDate > booking.EndBookingDate)
                    {
                        throw new Exception("End Booking date must be greater than start booking date");
                    }
                    string add = _bookingManager.CreateBooking(booking);
                    if (add == "Exist")
                    {
                        int custId = (int)Session["Id"];
                        ViewBag.VehicleId = new SelectList(_vehicleManager.GetAllVehicleByCustomer(custId), "VehicleId", "LicencePlate");
                        ViewBag.ServiceId = new SelectList(_serviceManager.GetAllService(), "ServiceId", "ServiceName");
                        ModelState.AddModelError("", "Booking already register");
                        var Bookings = new BookingViewModel()
                        {
                            bookinglist = _bookingManager.GetAllBooking()
                        };
                        return(View(Bookings));
                    }
                    else
                    {
                        Log.Info("Booking added Successffuly");
                        return(RedirectToAction("Index"));
                    }
                }
            }
            // Catch the exception
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
                ModelState.AddModelError("", "Error in booking uploading");
            }
            int custiId = (int)Session["Id"];

            ViewBag.VehicleId = new SelectList(_vehicleManager.GetAllVehicleByCustomer(custiId), "VehicleId", "LicencePlate");
            ViewBag.ServiceId = new SelectList(_serviceManager.GetAllService(), "ServiceId", "ServiceName");
            var bookings = new BookingViewModel()
            {
                bookinglist = _bookingManager.GetAllBooking()
            };

            return(View(bookings));
        }
コード例 #3
0
        public ActionResult Index()
        {
            IEnumerable <BookingViewModel> booking = _bookingManager.GetAllBooking().Where(a => a.DepartmentId == 3 && a.Status == 2).Reverse();;

            return(View(booking.ToList()));
        }
コード例 #4
0
        // GET: Booking
        // GET: Dealers
        public ActionResult Index()
        {
            IEnumerable <BookingViewModel> booking = _bookingManager.GetAllBooking().Reverse();

            return(View(booking.ToList()));
        }