Пример #1
0
        /// <summary>
        /// Async method that calls the async delete method from the persistancyService that deletes the selected booking's Tavle booking from the database
        /// </summary>
        public static async Task CancelTavleBookingMethodAsync()
        {
            // Checks if the user wants to delete the TavleBooking, or not
            var result = await DialogHandler.GenericYesNoDialog("Er du sikker på du vil Aflyse tavlen for denne bookning?\nDin Booking på rummet vil ikke blive slettet\nEn kvittering vil blive tilsendt for aflysning af denne tavle tid", "Aflys Tavle?", "Ja, Aflys Tavle", "Fortryd");

            // If user wants to delete the booking.
            if (result)
            {
                // Try and run the code, if the code cant run, catch the exception and notify the user that something went wrong.
                try
                {
                    // Gets the selected booking's tavlebooking as an object.
                    TavleBooking _selectedTavleBooking = TavleBookingCatalogSingleton.Instance.TavleBookings.Single(t => t.Booking_Id == Reference.SelectedBooking.Booking_Id);
                    // The async delete method from PersistancyService.
                    PersistancyService.DeleteFromDatabaseAsync("TavleBookings", _selectedTavleBooking.Tavle_Id);
                    // Deletes the selected object from the singleton observable collection, which in turn updates the view.
                    TavleBookingCatalogSingleton.Instance.TavleBookings.Remove(_selectedTavleBooking);

                    MailService.MailSenderAsync(LoginHandler.SelectedUser.User_Email, "Kvittering på aflysning af tavle booking", $"Du har aflyst din tavletid for rum: {Reference.SelectedBooking.RoomName} " +
                                                $"d. {Reference.SelectedBooking.Date.ToString("dd/MM/yyyy")} " +
                                                $"mellem {new DateTime(_selectedTavleBooking.Time_start.Ticks).ToString("HH:mm")} og {new DateTime(_selectedTavleBooking.Time_end.Ticks).ToString("HH:mm")}.", true);
                    //Update the viewpage
                    Reference.AflysTavleBtnVisibility = Visibility.Collapsed;
                    Reference.BookTavleBtnVisibility  = Visibility.Visible;
                    Reference.SelectedTavleBooking    = null;
                    Reference.CheckIfTavleBookingExists();
                }
                catch (Exception)
                {
                    // Informs the user that something went wrong with the deletion of a tavle booking
                    DialogHandler.Dialog("Noget gik galt med aflysning af tavle, kontakt Zealands IT-Helpdesk for mere information.", "Fejl i aflysning");
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Creates new booking object in the database and sends an email with confirmation of the booking, if the conditions are met.
        /// </summary>
        public async void CreateBookingAsync()
        {
            bool bookedAlready = true;

            foreach (var item in BookingCatalogSingleton.Instance.Bookings)
            {
                if (item.User_Id == LoginHandler.SelectedUser.User_Id && item.Date ==
                    RoomReference.Date && item.Time_end >= RoomReference.TimeStart && item.Time_start <= RoomReference.TimeEnd && LoginHandler.SelectedUser.Teacher == false)
                {
                    DialogHandler.Dialog("Du har allerede booket et lokale på denne dato i samme tidsinterval. Vælg venligst et nyt tidspunkt.", "Overlappende booking");
                    bookedAlready = false;
                    break;
                }
            }

            if (LoginHandler.SelectedUser.Teacher)
            {
                if (ThreeRoomsBookingLimit() == false)
                {
                    bookedAlready = false;
                    DialogHandler.Dialog("Du kan ikke have mere end tre bookinger af gangen, hvis du vil booke dette rum må du slette en anden booking", "Kun tre bookinger");
                }
            }
            if (bookedAlready)
            {
                // I don't know why, but we need this reference to get the RoomName property in the RoomsView model.
                RoomsView selectedRoomsViewRef = RoomReference.SelectedRoomsView;
                var       result = await DialogHandler.GenericYesNoDialog("Er du sikker på du vil booke dette lokale?", "Book lokale?", "Ja, tak", "Nej, tak");

                if (CompareDatesAndTime() && result)
                {
                    Booking booking = new Booking()
                    {
                        Date       = RoomReference.Date.Date,
                        Room_Id    = selectedRoomsViewRef.Room_Id,
                        Time_start = new TimeSpan(RoomReference.TimeStart.Hours, RoomReference.TimeStart.Minutes, 0),
                        Time_end   = new TimeSpan(RoomReference.TimeEnd.Hours, RoomReference.TimeEnd.Minutes, 0),
                        User_Id    = LoginHandler.SelectedUser.User_Id
                    };

                    await PersistancyService.SaveInsertAsJsonAsync(booking, "Bookings");

                    BookingCatalogSingleton.Instance.Bookings.Clear();
                    await BookingCatalogSingleton.Instance.LoadbookingsAsync();

                    FilterSearchMethodAsync();
                    // Does not need to be awaited, since it doesn't disrupt the flow of the program.
                    MailService.MailSenderAsync(LoginHandler.SelectedUser.User_Email, "Kvittering på booking", $"Du har booket {selectedRoomsViewRef.RoomName} " +
                                                $"d. {RoomReference.Date.ToString("dd/MM/yyyy")} " +
                                                $"mellem {new DateTime(RoomReference.TimeStart.Ticks).ToString("HH:mm")} og {new DateTime(RoomReference.TimeEnd.Ticks).ToString("HH:mm")}.", true);
                    RoomReference.SelectedRoomsView = null;
                }
            }
        }
Пример #3
0
        /// <summary>
        /// This method replaces every booking on a room in between the selected timeend and timestart
        /// </summary>
        /// <returns></returns>
        public async Task TeacherSnatchRoom()
        {
            var query = (from b in BookingCatalogSingleton.Instance.Bookings
                         where b.Room_Id == TCPREF.BookingIsSelected.Room_Id && TCPREF.BookingIsSelected.Date.Date == b.Date.Date && b.Time_end >= TCPREF.InputTimeStart && b.Time_start <= TCPREF.InputTimeEnd
                         select b).ToList();

            if (query.Count > 0)
            {
                foreach (var item in query)
                {
                    PersistancyService.DeleteFromDatabaseAsync("Bookings", item.Booking_Id);

                    await GetMailToUser(item.User_Id, "En lærer aflyste din booking", $"Din booking den " + $"{TCPREF.BookingIsSelected.Date.ToString("dd/MM/yyyy")} fra " + $"{new DateTime(TCPREF.BookingIsSelected.BookingStart.Ticks).ToString("HH:mm")} til " + $"{new DateTime(TCPREF.BookingIsSelected.BookingEnd.Ticks).ToString("HH:mm")} i rum {TCPREF.BookingIsSelected.RoomName} " + $"er blevet aflyst af {LoginHandler.SelectedUser.User_Name}, vi beklager ulejligheden. " + $"Du er selvfølgelig velkommen til at booke et nyt rum i appen.", true);
                }
                await PersistancyService.SaveInsertAsJsonAsync(new Booking
                {
                    Date          = TCPREF.BookingIsSelected.Date.Date,
                    Room_Id       = TCPREF.BookingIsSelected.Room_Id,
                    TavleBookings = null,
                    Time_start    = new TimeSpan(TCPREF.InputTimeStart.Hours, TCPREF.InputTimeStart.Minutes, 0),
                    Time_end      = new TimeSpan(TCPREF.InputTimeEnd.Hours, TCPREF.InputTimeEnd.Minutes, 0),
                    User_Id       = LoginHandler.CurrentUserId
                }, "Bookings");

                MailService.MailSenderAsync(LoginHandler.SelectedUser.User_Email, "Kvittering på booking", $"Du har booket {TCPREF.BookingIsSelected.RoomName} " + $"d. {TCPREF.BookingIsSelected.Date.ToString("dd/MM/yyyy")} " + $"mellem {new DateTime(TCPREF.BookingIsSelected.BookingStart.Ticks).ToString("HH:mm")} og {new DateTime(TCPREF.BookingIsSelected.BookingEnd.Ticks).ToString("HH:mm")}.", true);
                ResetList();
                DialogHandler.Dialog("Din booking er nu oprettet. God dag!", "Booking Oprettet!");
            }

            if (query.Count <= 0)
            {
                var result = await DialogHandler.GenericYesNoDialog(
                    "Der er ikke nogen booking på dit valgte tidspunkt, er du sikker på at du valgte det rigtige tidspunkt?",
                    "Ingen booking på valgte tidspunkt", "Opret Ny booking i stedet", "Indtast tid igen");

                if (result)
                {
                    await PersistancyService.SaveInsertAsJsonAsync(new Booking
                    {
                        Date          = TCPREF.BookingIsSelected.Date.Date,
                        Room_Id       = TCPREF.BookingIsSelected.Room_Id,
                        TavleBookings = null,
                        Time_start    = new TimeSpan(TCPREF.InputTimeStart.Hours, TCPREF.InputTimeStart.Minutes, 0),
                        Time_end      = new TimeSpan(TCPREF.InputTimeEnd.Hours, TCPREF.InputTimeEnd.Minutes, 0),
                        User_Id       = LoginHandler.CurrentUserId
                    }, "Bookings");

                    MailService.MailSenderAsync(LoginHandler.SelectedUser.User_Email, "Kvittering på booking", $"Du har booket {TCPREF.BookingIsSelected.RoomName} " + $"d. {TCPREF.BookingIsSelected.Date.ToString("dd/MM/yyyy")} " + $"mellem {new DateTime(TCPREF.BookingIsSelected.BookingStart.Ticks).ToString("HH:mm")} og {new DateTime(TCPREF.BookingIsSelected.BookingEnd.Ticks).ToString("HH:mm")}.", true);
                    ResetList();
                    DialogHandler.Dialog("Din booking er nu oprettet. God dag!", "Booking Oprettet!");
                }
            }
        }
Пример #4
0
 /// <summary>
 /// This method filters the listview with the correct objects
 /// </summary>
 public void FilterMethod()
 {
     if (TCPREF.InputTimeStart >= TCPREF.InputTimeEnd)
     {
         DialogHandler.Dialog("Vælg venligst en gyldig start- og sluttid.", "Ugyldigt tidspunkt");
     }
     else if (TCPREF.InputDate.Date < DateTime.Now.Date)
     {
         DialogHandler.Dialog("Vælg venligst en gyldig dato fra denne måned eller frem", "Ugyldig dato");
     }
     else
     {
         ResetList();
     }
 }
Пример #5
0
 /// <summary>
 /// First compares times to see if a valid time has been selected. Afterwards it checks if a valid date has been selected. If both are valid, it returns true.
 /// </summary>
 public bool CompareDatesAndTime()
 {
     if (RoomReference.TimeStart >= RoomReference.TimeEnd || RoomReference.TimeStart == TimeSpan.Zero || RoomReference.TimeEnd == TimeSpan.Zero)
     {
         DialogHandler.Dialog("Vælg venligst en gyldig start- og sluttid. Starttid eller sluttid kan ikke være 00.", "Ugyldigt tidspunkt");
         return(false);
     }
     else if (RoomReference.Date.DateTime < currentDate)
     {
         DialogHandler.Dialog("Vælg venligst en gyldig dato fra denne måned eller frem", "Ugyldig dato");
         return(false);
     }
     else
     {
         return(true);
     }
 }
Пример #6
0
        /// <summary>
        /// Method that checks for preconditions, before calling the BookTavle Method.
        /// </summary>
        public static async Task BookTavleMethodAsync()
        {
            TavleBooking myNewTavleBooking = null;
            TimeSpan     tavleEndTime      = Reference.SelectedTavleStartTime.Add(TimeSpan.Parse(Reference.SelectedDuration));

            if (Reference.SelectedTavleStartTime >= Reference.SelectedBooking.BookingStart && tavleEndTime <= Reference.SelectedBooking.BookingEnd)
            {
                if (tavleEndTime > Reference.SelectedBooking.BookingEnd)
                {
                    var endTimeExceedsBookingEnd = await DialogHandler.GenericYesNoDialog("Tiden kan ikke overstige sluttiden for denne booking.\nEr du sikker på du vil forsætte?\nDin tavletid vil blive begrænset!", "Begrænset Tavletid!", "Acceptér", "Fortryd");

                    if (endTimeExceedsBookingEnd)
                    {
                        tavleEndTime      = Reference.SelectedBooking.BookingEnd;
                        myNewTavleBooking = new TavleBooking()
                        {
                            Booking_Id = Reference.SelectedBooking.Booking_Id, Time_start = Reference.SelectedTavleStartTime, Time_end = tavleEndTime
                        };
                        await BookTavle(tavleEndTime, myNewTavleBooking);
                    }
                    else
                    {
                        return;
                    }
                }
                else if (Reference.SelectedTavleStartTime < Reference.SelectedBooking.BookingStart)
                {
                    DialogHandler.Dialog("Vælg venligt en anden starttid\nStarttiden kan ikke være mindre end start-tiden for denne booking", "Ugyldig tid");
                    return;
                }
                else
                {
                    myNewTavleBooking = new TavleBooking()
                    {
                        Booking_Id = Reference.SelectedBooking.Booking_Id, Time_start = Reference.SelectedTavleStartTime, Time_end = tavleEndTime
                    };
                    await BookTavle(tavleEndTime, myNewTavleBooking);
                }
            }
            else
            {
                DialogHandler.Dialog("Den valgte tavletid skal være inden for den bookede periode\nVælg venligst en anden tavletid", "Ugyldig tid");
            }
        }
Пример #7
0
 //this method has to be bound to the login button, in the PageLogin view
 public static void Login()
 {
     UserCatalogSingleton.Instance.LoadUsersAsync();
     if (UserName != null && Password != null)                                // Makes sure that password and username is filled out
     {
         if (CheckUserCredentials)                                            // Checks if password and username inputted matches in database.
         {
             ((Frame)Window.Current.Content).Navigate(typeof(PageLocations)); //redirect to the next page
         }
         else
         {
             Password = "";                                                             // this call clears the password box's textfield by Clearing the two-way-binded property UserName.
             DialogHandler.Dialog("Forkert brugernavn eller password", "Fejlet login"); // Error MessageBox
         }
     }
     else
     {
         DialogHandler.Dialog("Forkert brugernavn eller password", "Login fejlet"); //Error message
     }
 }
Пример #8
0
        /// <summary>
        /// This Method calls TeacherSnatchRoom if a series of conditions are met
        /// </summary>
        public async Task TeacherStealsBookingMethod()
        {
            var result = await DialogHandler.GenericYesNoDialog(
                $"Er du sikker på du vil booke dette lokale? {TCPREF.BookingIsSelected.RoomName}, ved at booke dette lokale aflyser du en eleves booking",
                "Er du sikker?", "Ja", "Nej");

            if (result)
            {
                if (LoginHandler.SelectedUser.Teacher)
                {
                    if (IsNotATeach())
                    {
                        if (TCPREF.BookingIsSelected.Date.Date >= DateTime.Now.Date.AddDays(3))
                        {
                            if (ThreeRoomsBookingLimit())
                            {
                                TeacherSnatchRoom();
                            }
                            else
                            {
                                DialogHandler.Dialog(
                                    "Du kan ikke have mere end tre bookinger af gangen, hvis du vil booke dette rum må du slette en anden booking",
                                    "Kun tre bookinger");
                            }
                        }
                        else
                        {
                            DialogHandler.Dialog("Der skal være minimum tre dages varsel før du kan booke et lokale",
                                                 "3-dages varsel-fejl!");
                        }
                    }
                    else
                    {
                        DialogHandler.Dialog("Den valgte booking indeholder en lærer-booking, det er desværre ikke muligt at slette en anden lærers booking", "lærer-booking fejl");
                    }
                }
            }
        }
Пример #9
0
        /// <summary>
        /// Method that posts the tavlebooking to the database, after it has checked if its possible in the chosen timespan.
        /// </summary>
        /// <param name="tavleEndTime">The total time for the selected tavlebooking (Comes from the Booktavle Method)</param>
        /// <param name="myTavleBooking">The chosen tavlebooking. This value comes from the SelectedDuration, and SelectedTavleStartTime properties</param>
        /// <returns></returns>
        public static async Task BookTavle(TimeSpan tavleEndTime, TavleBooking myNewTavleBooking)
        {
            AllBookingsView tempSelectedBooking = Reference.SelectedBooking;
            var             doesUserHaveAnyTavleBookingsForThisRoom = (from t in Reference.Tavlebookings
                                                                       select t).Where(x => x.Booking_Id == Reference.SelectedBooking.Booking_Id).ToList();

            if (doesUserHaveAnyTavleBookingsForThisRoom.Count > 0)
            {
                DialogHandler.Dialog("Det er ikke muligt at booke flere end 1 tavle\nSlet venligst eksisterende tavler og book derefter igen.", "For mange bookede tavler");
                return;
            }
            else
            {
                if (Reference.SelectedBooking.Type == "Klasselokale")
                {
                    var numberOfTavleBookingsForThisRoomOnThatDay = (from t in Reference.Tavlebookings
                                                                     join b in AllBookingsViewCatalogSingleton.Instance.AllBookings on t.Booking_Id equals b.Booking_Id
                                                                     select new
                    {
                        BookingId = t.Booking_Id,
                        UserId = b.User_Id,
                        RoomId = b.Room_Id,
                        BookingDate = b.Date,
                        BookingStart = b.BookingStart,
                        BookingEnd = b.BookingEnd,
                        TavleId = t.Tavle_Id,
                        TavleStart = t.Time_start,
                        TavleEnd = t.Time_end
                    }).Where(x => Reference.SelectedBooking.Room_Id == x.RoomId && Reference.SelectedBooking.Date == x.BookingDate).ToList();
                    if (numberOfTavleBookingsForThisRoomOnThatDay.Count > 0 && numberOfTavleBookingsForThisRoomOnThatDay.Count <= 2)
                    {
                        var checkTavleTime = (from t in numberOfTavleBookingsForThisRoomOnThatDay
                                              select t).Where(x => (Reference.SelectedTavleStartTime + TimeSpan.FromSeconds(1)) <= x.TavleEnd && (tavleEndTime - TimeSpan.FromSeconds(1)) >= x.TavleStart).ToList();
                        if (checkTavleTime.Count == 0)
                        {
                            // INSERT
                            if (await DialogHandler.GenericYesNoDialog("Er du sikker på du vil booke denne tavletid?\nKvittering på tavlen vil blive tilsendt via mail", "Book Book Tavle?", "Ja", "Fortryd"))
                            {
                                await PersistancyService.SaveInsertAsJsonAsync(myNewTavleBooking, "TavleBookings");

                                MailService.MailSenderAsync(LoginHandler.SelectedUser.User_Email, "Kvittering på booking af tavletid", $"Du har booked tavlen i rummet {Reference.SelectedBooking.RoomName}" +
                                                            $"d. {Reference.SelectedBooking.Date.ToString("dd/MM/yyyy")} " +
                                                            $"mellem {new DateTime(myNewTavleBooking.Time_start.Ticks).ToString("HH:mm")} og {new DateTime(myNewTavleBooking.Time_end.Ticks).ToString("HH:mm")}.", true);
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            DialogHandler.Dialog("Denne tid modstrider en anden tavle booking\nVælg venligst en tidligere eller senere tid", "Modstridende tider");
                        }
                    }
                    else
                    {
                        // INSERT
                        if (await DialogHandler.GenericYesNoDialog("Er du sikker på du vil booke denne tavletid?\nKvittering på tavlen vil blive tilsendt via mail", "Book Book Tavle?", "Ja", "Fortryd"))
                        {
                            await PersistancyService.SaveInsertAsJsonAsync(myNewTavleBooking, "TavleBookings");

                            MailService.MailSenderAsync(LoginHandler.SelectedUser.User_Email, "Kvittering på booking af tavletid", $"Du har booked tavlen i rummet {Reference.SelectedBooking.RoomName}" +
                                                        $"d. {Reference.SelectedBooking.Date.ToString("dd/MM/yyyy")} " +
                                                        $"mellem {new DateTime(myNewTavleBooking.Time_start.Ticks).ToString("HH:mm")} og {new DateTime(myNewTavleBooking.Time_end.Ticks).ToString("HH:mm")}.", true);
                        }
                        else
                        {
                            return;
                        }
                    }
                }
            }
            RefreshLists();
            Reference.SelectedBooking = tempSelectedBooking;
        }
Пример #10
0
        /// <summary>
        /// This method books the selected room again tomorrow, if that is possible.
        /// </summary>
        public static async Task BookAgainTomorrowMethodAsync()
        {
            // Retrieves the day after the selected booking date
            DateTime tomorrow = Reference.SelectedBooking.Date.AddDays(1);
            // The copied booking that needs to be inserted into the database with the updated date.
            Booking updatedBooking = new Booking()
            {
                User_Id    = Reference.SelectedUser.User_Id,
                Room_Id    = Reference.SelectedBooking.Room_Id,
                Date       = tomorrow,
                Time_start = Reference.SelectedBooking.BookingStart,
                Time_end   = Reference.SelectedBooking.BookingEnd
            };
            // This object will be set to the returned booking that gets posted to the database and later used in the AllBookingsView object
            Booking returnedObj = null;
            // This object is the view object that gets added to the singleton, to that the view will be updated.-
            AllBookingsView viewToAdd = null;
            // Checks how many instances there is of this selectedbooking's specific room.
            var howManyOfThisRoomTomorrowQuery = (from b in AllBookingsViewCatalogSingleton.Instance.AllBookings
                                                  select b).Where(x => Reference.SelectedBooking.Room_Id == x.Room_Id && x.Date == tomorrow).ToList();

            if (howManyOfThisRoomTomorrowQuery.Count == 2)
            {
                // checks if there is any instances that overlaps the selectedbookings's time
                var checkTime = (from b in howManyOfThisRoomTomorrowQuery
                                 select b).Where(x => Reference.SelectedBooking.BookingStart > x.BookingStart && Reference.SelectedBooking.BookingStart <x.BookingEnd || Reference.SelectedBooking.BookingEnd> x.BookingStart && Reference.SelectedBooking.BookingEnd < x.BookingEnd).ToList();
                // If 0 or less
                if (checkTime.Count < 1)
                {
                    var result = await DialogHandler.GenericYesNoDialog("Er du sikker på du vil booke dette rum igen imorgen samme tid?\nKvittering på bookning af det nye rum vil blive tilsendt via mail", "Book igen imorgen?", "Ja", "Fortryd");

                    if (result)
                    {
                        // Inserts the selectedbooking into the database and updates the singleton
                        returnedObj = await PersistancyService.SaveInsertAsJsonAsync(updatedBooking, "Bookings");

                        MailService.MailSenderAsync(LoginHandler.SelectedUser.User_Email, "Kvittering på booking af rum", $"Du har booked rummet {Reference.SelectedBooking.RoomName} igen for " +
                                                    $"d. {returnedObj.Date.ToString("dd/MM/yyyy")} " +
                                                    $"mellem {new DateTime(returnedObj.Time_start.Ticks).ToString("HH:mm")} og {new DateTime(returnedObj.Time_end.Ticks).ToString("HH:mm")}.", true);
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    // Error message that displays if there already exists a booking in the database that overlaps with the selectedbooking on the day after the selectedbooking date
                    DialogHandler.Dialog("Denne booking kan ikke bookes imorgen\nda den overlapper eksisterende bookninger", "Overlappende Bookninger");
                }
            }
            else
            {
                var result = await DialogHandler.GenericYesNoDialog("Er du sikker på du vil booke dette rum igen imorgen samme tid?\nKvittering på bookning af det nye rum vil blive tilsendt via mail", "Book igen imorgen?", "Ja", "Fortryd");

                if (result)
                {
                    // Inserts the selectedbooking into the database and updates the singleton
                    returnedObj = await PersistancyService.SaveInsertAsJsonAsync(updatedBooking, "Bookings");

                    MailService.MailSenderAsync(LoginHandler.SelectedUser.User_Email, "Kvittering på booking af rum", $"Du har booked rummet {Reference.SelectedBooking.RoomName} igen for " +
                                                $"d. {returnedObj.Date.ToString("dd/MM/yyyy")} " +
                                                $"mellem {new DateTime(returnedObj.Time_start.Ticks).ToString("HH:mm")} og {new DateTime(returnedObj.Time_end.Ticks).ToString("HH:mm")}.", true);
                }
                else
                {
                    return;
                }
            }
            if (returnedObj != null)
            {
                viewToAdd = new AllBookingsView()
                {
                    RoomName        = Reference.SelectedBooking.RoomName,
                    Date            = tomorrow,
                    Booking_Id      = returnedObj.Booking_Id,
                    BookingStart    = Reference.SelectedBooking.BookingStart,
                    BookingEnd      = Reference.SelectedBooking.BookingEnd,
                    Room_Id         = Reference.SelectedBooking.Room_Id,
                    Floor           = Reference.SelectedBooking.Floor,
                    No              = Reference.SelectedBooking.No,
                    Name            = Reference.SelectedBooking.Name,
                    Building_Letter = Reference.SelectedBooking.Building_Letter,
                    Type            = Reference.SelectedBooking.Type,
                    User_Id         = Reference.SelectedBooking.User_Id
                };
                // Adds the viewToAdd object, to the singleton
                Reference.AllUserBookingsFromSingleton.Add(viewToAdd);
                // Refreshes the singleton, and re-queries the bookings for the selected user
                RefreshLists();
                // sets the selected booking to the newly added booking
                Reference.SelectedBooking = Reference.AllUserBookingsFromSingleton.First();
            }
        }