//
        // GET: /Reservations/Create/id_demande

        public ActionResult Create(int id)
        {
            var                   demandeAssociee = this.demandesRepository.Find(id);
            List <Salle>          salles          = this.sallesRepository.GetSallesCriteres(demandeAssociee.CapaciteNecessaire, demandeAssociee.BesoinProjecteur, demandeAssociee.DateVoulue).ToList();
            List <CreneauHoraire> creneaux        = this.creneauxRepository.getCreneauxHorairesForDate(demandeAssociee.DateVoulue).ToList();



            // Print a nice calendar.
            List <Reservation> reservationsGroupe = this.repository.GetReservationsForGroupe(demandeAssociee.Enseignement.Groupe.Id).ToList();

            ViewBag.calendarId   = "CalendarCreateReservation_" + id;
            ViewBag.calendarJSON = ReservationCalendar.ReservationsToJson(reservationsGroupe);



            ViewBag.demandeAssociee = demandeAssociee;
            ViewBag.creneaux        = creneaux;
            ViewBag.salles          = salles;
            ViewBag.DemandeId       = id;
            return(View(new Reservation()
            {
                Date = demandeAssociee.DateVoulue, Enseignement = new Enseignement()
                {
                    Id = demandeAssociee.Enseignement.Id
                }
            }));
        }
Exemplo n.º 2
0
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            Car temp = (Car)carToBeDeleted.SelectedItem;

            if (temp == null)
            {
                System.Windows.MessageBox.Show("Please select car.");
                return;
            }
            int idToBeDeleted = temp.id;

            if (!ReservationCalendar.checkIfCarHasNoReservations(idToBeDeleted))
            {
                System.Windows.MessageBox.Show("Car can not be deleted because of reservations.");
                return;
            }

            CarList.deleteCarFromList(idToBeDeleted);
            System.Windows.MessageBox.Show("Car deleted!");

            Admin_ControlPanel admin_ControlPanel = new Admin_ControlPanel(Left, Top);

            admin_ControlPanel.Show();
            Close();
        }
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            User temp = (User)userToBeDeleted.SelectedItem;

            if (temp == null)
            {
                System.Windows.MessageBox.Show("Please select user.");
                return;
            }
            int tempUserId = temp.id;

            if (!ReservationCalendar.checkIfUserHasNoReservations(tempUserId))
            {
                System.Windows.MessageBox.Show("User can not be deleted because of reservations.");
                return;
            }
            UserList.deleteUserFromList(tempUserId);
            ReservationCalendar.deleteUserPastReservations(tempUserId);
            System.Windows.MessageBox.Show("User deleted!");

            Admin_ControlPanel admin_ControlPanel = new Admin_ControlPanel(Left, Top);

            admin_ControlPanel.Show();
            Close();
        }
Exemplo n.º 4
0
        //
        // GET: /Manager/

        public ActionResult Index()
        {
            var id = (int)Membership.GetUser().ProviderUserKey;

            ViewBag.unseen = this.demandesRepository.GetUnseenDemandes(id);

            Enseignant ens = this.enseignantsRepository.Get(id);

            ViewBag.login = ens.UserName;

            List <Reservation> resa = this.reservationsRepository.GetReservationsFor(id).ToList();

            // Static method
            ViewBag.calendarJSON = ReservationCalendar.ReservationsToJson(resa);

            ViewBag.calendarId = "CalendarManager";


            if (Roles.IsUserInRole(User.Identity.Name, "ResponsableUE"))
            {
                ViewBag.demandesAVerifCount = this.demandesRepository.GetReservationTo(id).Count();

                if (!Request.IsAjaxRequest())
                {
                    return(View("Responsable"));
                }
                else
                {
                    return(PartialView("_Responsable"));
                }
            }

            else if (Roles.IsUserInRole(User.Identity.Name, "Administrateur"))
            {
                if (!Request.IsAjaxRequest())
                {
                    return(View("Administrateur"));
                }
                else
                {
                    return(PartialView("_Administrateur"));
                }
            }
            else if (Roles.IsUserInRole(User.Identity.Name, "Enseignant"))
            {
                if (!Request.IsAjaxRequest())
                {
                    return(View("Enseignant"));
                }
                else
                {
                    return(PartialView("_Enseignant"));
                }
            }

            else
            {
                return(View());
            }
        }
        public static void GenerateSpecificUserSummary(int userID)
        {
            List <Reservation> userPastReservations = ReservationCalendar.GetSpecificUserPastReservations(userID);

            List <string> output = new List <string>();
            string        currentlyLoggedUsername = CurrentlyLoggedUser.GetSpecificUserUsername();
            string        filePath  = $"{currentlyLoggedUsername}Summary.txt";
            string        firstLine = $"Reservation summary for client {currentlyLoggedUsername}:";

            output.Add(firstLine);
            int totalSpentSum = 0;
            int totalRentDays = 0;

            foreach (var reservation in userPastReservations)
            {
                DateTime pickUp            = Convert.ToDateTime(reservation.rentedFrom);
                DateTime dropOff           = Convert.ToDateTime(reservation.rentedTo);
                int      numberOfRentDays  = (dropOff.Date - pickUp.Date).Days;
                int      oneReservationSum = CarList.getSpecificCarRentPrice(reservation.carId) * numberOfRentDays;
                totalSpentSum += oneReservationSum;
                totalRentDays += numberOfRentDays;

                output.Add($"Car {CarList.getSpecificCarName(reservation.carId)} rented from {reservation.rentedFrom} to {reservation.rentedTo} ({numberOfRentDays} days)" +
                           $" for total of {oneReservationSum}PLN");
            }
            string lastLine = $"Total sum spent: {totalSpentSum}PLN, total rent days: {totalRentDays}";

            output.Add(lastLine);
            File.WriteAllLines(filePath, output);
        }
Exemplo n.º 6
0
        private void RentButton_Click(object sender, RoutedEventArgs e)
        {
            string   tempPickUpDate  = "";
            string   tempDropOffDate = "";
            DateTime dropOff;
            DateTime pickUp;
            DateTime currentDate = DateTime.Now;


            try
            {
                pickUp         = (DateTime)pickUpDate.SelectedDate;
                tempPickUpDate = pickUp.ToShortDateString();
            }
            catch (Exception)
            {
                System.Windows.MessageBox.Show("Please fill in pick-up date!");
                return;
            }

            try
            {
                dropOff         = (DateTime)dropOffDate.SelectedDate;
                tempDropOffDate = dropOff.ToShortDateString();
            }
            catch (Exception)
            {
                System.Windows.MessageBox.Show("Please fill in drop-off date!");
                return;
            }
            if (dropOff < pickUp)
            {
                System.Windows.MessageBox.Show("We do not rent cars to time travellers ;)");
                return;
            }
            else if (dropOff == pickUp)
            {
                System.Windows.MessageBox.Show("We do not rent cars for hours.");
                return;
            }

            Reservation reservation = new Reservation(CurrentlyLoggedUser.currentlyLoggedUserId, selectedCar.id, tempPickUpDate, tempDropOffDate);

            if (!ReservationCalendar.CheckIfReservationIsPossible(reservation))
            {
                return;
            }

            System.Windows.MessageBox.Show("Reservation is complete!");
            ReservationCalendar.AddNewReservationToList(reservation);
            Cars_window.isRentWindowOpened = false;
            Close();
        }
Exemplo n.º 7
0
        private void initializeReservationsList()
        {
            reservationsList = new List <ReservationDataGridInfo>();

            foreach (var reservation in ReservationCalendar.reservationCalendar)
            {
                ReservationDataGridInfo temp = new ReservationDataGridInfo();
                temp.carId                = reservation.carId;
                temp.rentedFrom           = reservation.rentedFrom;
                temp.rentedTo             = reservation.rentedTo;
                temp.carName              = CarList.getSpecificCarName(reservation.carId);
                temp.borrowerUsername     = UserList.getUsername(reservation.borrowerId);
                temp.imageFilePath        = CarList.getSpecificCarImage(reservation.carId);
                temp.totalReservationCost = ReservationCalendar.calculateTotalReservationCost(reservation.carId);

                reservationsList.Add(temp);
            }
        }
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            ReservationComboBoxInfo temp = (ReservationComboBoxInfo)reservationsComboBox.SelectedItem;

            if (temp == null)
            {
                System.Windows.MessageBox.Show("Please select reservation.");
                return;
            }
            Reservation resToDelete = new Reservation(CurrentlyLoggedUser.currentlyLoggedUserId, temp.carId, temp.rentedFrom, temp.rentedTo);

            ReservationCalendar.deleteReservationFromList(resToDelete);

            System.Windows.MessageBox.Show("Reservation deleted!");
            User_ControlPanel user_ControlPanel = new User_ControlPanel(Left, Top);

            user_ControlPanel.Show();
            Close();
        }
Exemplo n.º 9
0
        private void BlackoutDates(int carId)
        {
            List <Reservation> selectedCarReservations = ReservationCalendar.GetSpecificCarReservationCalendar(carId);

            if (selectedCarReservations.Count == 0)
            {
                return;
            }

            foreach (var reservation in selectedCarReservations)
            {
                DateTime temp1 = Convert.ToDateTime(reservation.rentedFrom);
                DateTime temp2 = Convert.ToDateTime(reservation.rentedTo);
                temp1 = temp1.AddDays(1);
                temp2 = temp2.AddDays(-1);
                pickUpDate.BlackoutDates.Add(new CalendarDateRange(temp1, temp2));
                dropOffDate.BlackoutDates.Add(new CalendarDateRange(temp1, temp2));
            }
        }