Exemple #1
0
 public TimetableModel(List<Room> Rooms, List<TimeSlot> Times, Booking[,] Bookings, DateTime Day)
 {
     this.Rooms = Rooms;
     this.Times = Times;
     this.Bookings = Bookings;
     this.Day = Day;
     ValidTimetable = true;
 }
Exemple #2
0
        private void SetCabinBagToItinerary(
            Data.Models.Booking booking,
            ref decimal totalCost,
            Literal cabinBagLiteral,
            Literal cabinBabPriceLiteral)
        {
            var cabinBag = booking.Baggage
                           .FirstOrDefault(b => b.Type == BaggageType.Cabin);

            if (cabinBag != null)
            {
                cabinBagLiteral.Text      = "One cabin bag " + cabinBag.Size;
                cabinBabPriceLiteral.Text = "&#8364; " + string.Format("{0:0.00}", cabinBag.Price);
                totalCost += cabinBag.Price;
            }
        }
Exemple #3
0
        // Set baby, sports and music equipments to the itenerary info panel.
        private void SetBagEquipmentsToItinerary(
            Data.Models.Booking booking,
            ref decimal totalCost,
            BaggageType baggageType,
            Literal literalInfo,
            Literal literalPrice)
        {
            var equipment = booking.Baggage
                            .FirstOrDefault(b => b.Type == baggageType);

            if (equipment != null)
            {
                literalInfo.Text  = string.Format("{0} equipment included!", this.GetBagEquiptmentAsString(baggageType));
                literalPrice.Text = "&#8364; " + string.Format("{0:0.00}", equipment.Price);
                totalCost        += equipment.Price;
            }
        }
Exemple #4
0
        private void SetCheckedInBagsToItinerary(
            Data.Models.Booking booking,
            ref decimal totalCost,
            Literal checkedInBagsLiteral,
            Literal checkedInBagsPricesLiteral)
        {
            var checkedInBags = booking.Baggage
                                .Where(b => b.Type == BaggageType.CheckedIn)
                                .ToList();

            if (checkedInBags.Count > 0)
            {
                checkedInBagsLiteral.Text = "Checked in bags " + checkedInBags.Count + " x " +
                                            checkedInBags[0].MaxKilograms + " kg. ";

                decimal checkedInBagsPriceSum = checkedInBags.Sum(b => b.Price);
                checkedInBagsPricesLiteral.Text = "&#8364; " + string.Format("{0:0.00}", checkedInBagsPriceSum);
                totalCost += checkedInBagsPriceSum;
            }
        }
Exemple #5
0
        // Tries to send an email to the Teacher specified by the given Booking,
        // containing information on the booking itself, and whether it was edited/created
        public static bool Send(Booking Booking, bool Edited)
        {
            try
            {
                // Make a new Email socket
                using (SmtpClient Client = new SmtpClient(SMTPServer, SMTPPort))
                {
                    // Secure, specific credentials, over network delivery
                    Client.EnableSsl = true;
                    Client.UseDefaultCredentials = false;
                    Client.Credentials = new NetworkCredential(SenderAddress, SenderPassword);
                    Client.DeliveryMethod = SmtpDeliveryMethod.Network;

                    // Create the message and fill out the fields
                    MailMessage Message = new MailMessage();
                    Message.From = new MailAddress(SenderAddress);
                    Message.To.Add(new MailAddress(Booking.Teacher.Email));

                    // Pick an appropriate subject based on what happened to the booking
                    Message.Subject = Edited ? "One of your bookings has been edited" : "You've made a new booking";
                    // Fill out the body using information from the Booking object
                    Message.Body = (Edited ? "One of your bookings has been edited." : "You've made a new booking.") + "\r\n\r\n" +
                        "Date: " + Booking.Date.ToShortDateString() + "\r\n" +
                        "Period: " + Booking.TimeSlot + "\r\n" +
                        "Rooms: " + Booking.Rooms.Aggregate("", (a, r) => { return a + r.RoomName + ", "; }).TrimEnd(',', ' ') + "\r\n" +
                        "Recurrence: " + Booking.BookingType + "\r\n" +
                        "Subject: " + Booking.Subject.SubjectName + "\r\n" +
                        "Students: " + Booking.Students.Count + "\r\n";

                    // Send off the message
                    Client.SendAsync(Message, null);
                }
            }
            catch
            {
                return false;
            }

            return true;
        }
        public TimetableTile(Booking Booking, TimeSlot Time, Room Room, User CurrentUser)
        {
            // Sets UI bindings to reference this object
            DataContext = this;

            this.Booking = Booking;
            this.Time = Time;
            this.Room = Room;

            // Set the default brightness function to the default
            BrightnessCurve = DefaultBrightnessCurve;

            // Default to the background window colour
            Brush = SystemColors.WindowBrush;
            if (Booking != null) // If there's actually a booking in this slot, use its colour
                Brush = new SolidColorBrush(Booking.Subject.Colour);
            Background = Brush;

            // Initialise the UI
            InitializeComponent();

            // Hook up mouse events
            MouseEnter += TimetableTile_MouseEnter;
            MouseLeave += TimetableTile_MouseLeave;

            // If there's a booking in this slot
            if (Booking != null && CurrentUser != null)
            {
                // If the current user is somehow involved in the booking (either
                // as a student or teacher)
                if (((CurrentUser is Student) && Booking.Students.Any(s => s.Id == CurrentUser.Id)) ||
                    ((CurrentUser is Teacher) && Booking.Teacher.Id == CurrentUser.Id))
                {
                    // Do a simple animation on the tiles to draw attention
                    Storyboard PulseEffect = (Storyboard)Resources["PulseEffect"];
                    PulseEffect.Begin(Outer);
                }
            }
        }
Exemple #7
0
        private void SetSelectedFlightToItinerary(
            Data.Models.Booking booking,
            ref decimal totalCost,
            Literal flightNumberLiteral,
            Literal dateTimeLiteral,
            Literal flightPriceLiteral,
            Literal travelClassPriceLiteral,
            Literal travelClassLiteral)
        {
            LegInstance selectedLegInstance = this.LegInstancesServices.GetLegInstance(booking.LegInstanceId);

            flightNumberLiteral.Text = "Flight № " + selectedLegInstance.FlightLeg.Flight.Number;
            dateTimeLiteral.Text     = selectedLegInstance.DepartureDateTime.ToString("MMMM dd, yyyy hh:mm", CultureInfo.InvariantCulture);

            flightPriceLiteral.Text = "&#8364; " + string.Format("{0:0.00}", selectedLegInstance.Price);

            decimal travelClassPrice = this.TravelClassesServices.GetTravelClass(booking.TravelClassId).Price;

            travelClassPriceLiteral.Text = "&#8364; " + string.Format("{0:0.00}", travelClassPrice);
            totalCost += selectedLegInstance.Price + travelClassPrice;

            travelClassLiteral.Text = this.TravelClassesServices.GetTravelClass(booking.TravelClassId).Type.ToString() + " class";
        }
Exemple #8
0
        private void SetItineraryForBooking(
            Data.Models.Booking booking,
            ref decimal totalCost,
            Literal seatLiteral,
            Literal flightNumberLiteral,
            Literal dateTimeLiteral,
            Literal flightPriceLiteral,
            Literal travelClassPriceLiteral,
            Literal travelClassLiteral)
        {
            this.SetSelectedFlightToItinerary(
                booking,
                ref totalCost,
                flightNumberLiteral,
                dateTimeLiteral,
                flightPriceLiteral,
                travelClassPriceLiteral,
                travelClassLiteral);

            if (booking.Row > 0 && !string.IsNullOrEmpty(booking.SeatNumber))
            {
                seatLiteral.Text = booking.Row.ToString() + booking.SeatNumber;
            }
        }