Ejemplo n.º 1
0
        public ActionResult ReservationConfirmed(checkoutviewmodel vm)
        {
            MailMessage mail = new MailMessage();

            mail.To.Add(vm.Email);
            mail.From    = new MailAddress("*****@*****.**");
            mail.Subject = "Team 5: Reservation Complete";
            mail.Body    = "Your reservation has been confirmed. " +
                           "Name: " + vm.FirstName + " " + vm.LastName +
                           "Flight: " + vm.Flightnumber +
                           "Seat: " + vm.SeatName +
                           "AdvantageNumber: " + vm.AdvantageNumber +
                           "Depart Date: " + vm.DepartDateTime +
                           "Total Paid w/o tax: " + vm.PreTotal +
                           "Total Paid: " + vm.PreTotal * 1.0775m;
            mail.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient();

            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;
            smtp.UseDefaultCredentials = false;
            smtp.Credentials           = new System.Net.NetworkCredential("team5penguinairlines", "ihatepenguinairlines"); // Enter seders User name and password
            smtp.EnableSsl             = true;
            smtp.Send(mail);
            return(View(vm));
        }
Ejemplo n.º 2
0
        public ActionResult ReturnGetCustomer()
        {
            Int32       maxID              = db.Reservations.Max(x => x.ReservationID);
            Reservation newestReservation  = db.Reservations.Find(maxID);
            List <Seat> seatsWithNewTicket = db.Seats.Where(x => x.IsAvailable == false && x.Ticket.Reservation.ReservationID == newestReservation.ReservationID && x.Ticket.Customer == null).ToList();

            if (seatsWithNewTicket.Count == 0)
            {
                checkoutviewmodel vm = new checkoutviewmodel();
                return(RedirectToAction("DeterminePaymentType", "Checkout"));
            }
            return(View(seatsWithNewTicket));
        }
Ejemplo n.º 3
0
        public ActionResult ShowTotal()
        {
            checkoutviewmodel vm                        = new checkoutviewmodel();
            decimal           total                     = vm.Total;
            Int32             maxID                     = db.Reservations.Max(x => x.ReservationID);
            Reservation       newestReservation         = db.Reservations.Find(maxID);
            List <Ticket>     ReservationWithNewTickets = db.Tickets.Where(x => x.Reservation.ReservationID == newestReservation.ReservationID).ToList();
            string            UserId                    = User.Identity.GetUserId();
            AppUser           LoggedIn                  = db.Users.Find(UserId);

            if (LoggedIn.EmpType == "Customer")
            {
                newestReservation.PrimaryTravelerID = LoggedIn;
                db.SaveChanges();
            }
            else if (newestReservation.PrimaryTravelerID == null && (LoggedIn.EmpType == "Agent" || LoggedIn.EmpType == "Manager"))
            {
                return(RedirectToAction("ChoosePrimaryTraveler"));
            }


            foreach (Ticket ThisTicket in ReservationWithNewTickets)
            {
                total += ThisTicket.ActualFare + ThisTicket.EarlyDiscount + ThisTicket.ChildDiscount + ThisTicket.SeniorDiscount + ThisTicket.InternetDiscount;
                ThisTicket.DiscountedFare = ThisTicket.ActualFare + ThisTicket.EarlyDiscount + ThisTicket.ChildDiscount + ThisTicket.SeniorDiscount + ThisTicket.InternetDiscount;
                db.SaveChanges();

                vm.Email           = ThisTicket.Customer.Email;
                vm.FirstName       = ThisTicket.Customer.FirstName;
                vm.LastName        = ThisTicket.Customer.LastName;
                vm.Flightnumber    = ThisTicket.Flight.FlightNumber.Number;
                vm.SeatName        = ThisTicket.Seat.SeatName;
                vm.AdvantageNumber = ThisTicket.Customer.AdvantageNumber;
                vm.DepartDateTime  = ThisTicket.Flight.DepartDateTime;
                vm.DiscountedFare  = ThisTicket.DiscountedFare;
                vm.PreTotal       += total;

                MailModelsController c         = new MailModelsController();
                ActionResult         newresult = c.ReservationConfirmed(vm);
            }
            vm.Tickets  = ReservationWithNewTickets;
            vm.PreTotal = total;

            vm.Total = total * 1.0775m;
            return(View(vm));
        }
Ejemplo n.º 4
0
        public ActionResult FlightCancelled(checkoutviewmodel vm)
        {
            MailMessage mail = new MailMessage();

            mail.To.Add(vm.Email);
            mail.From    = new MailAddress("*****@*****.**");
            mail.Subject = "Team 5: Flight Cancelled";
            mail.Body    = "Your flight (" + vm.Flightnumber +
                           "departing at" + vm.DepartDateTime +
                           "has been cancelled.";
            mail.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient();

            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;
            smtp.UseDefaultCredentials = false;
            smtp.Credentials           = new System.Net.NetworkCredential("team5penguinairlines", "ihatepenguinairlines"); // Enter seders User name and password
            smtp.EnableSsl             = true;
            smtp.Send(mail);
            return(View("Index", "Home"));
        }
Ejemplo n.º 5
0
        public ActionResult Edit([Bind(Include = "FlightNumberID,Number,DepartTime,BaseFare,BeenDisabled")] FlightNumber flightNumber, int[] DaysChosenList)
        {
            if (ModelState.IsValid)
            {
                checkoutviewmodel vm = new checkoutviewmodel();
                FlightNumber      flightNumbertochange = db.FlightNumbers.Find(flightNumber.FlightNumberID);
                List <Day>        newdeparturedaylist  = new List <Day>();
                foreach (int Dayofweek in DaysChosenList)
                {
                    newdeparturedaylist.Add(db.Days.Find(Dayofweek));
                }
                if (flightNumbertochange.DepartureDays.ToList() != newdeparturedaylist)
                {
                    flightNumbertochange.DepartureDays = newdeparturedaylist;
                }

                if (flightNumbertochange.DepartTime != flightNumber.DepartTime)
                {
                    flightNumbertochange.DepartTime = flightNumber.DepartTime;
                }

                if (flightNumbertochange.BaseFare != flightNumber.BaseFare)
                {
                    flightNumbertochange.BaseFare = flightNumber.BaseFare;
                }
                flightNumbertochange.BeenDisabled = flightNumber.BeenDisabled;
                Boolean safe = false;
                foreach (Flight flight in db.Flights.Where(c => c.FlightNumber.Number == flightNumbertochange.Number).Where(c => c.DepartDateTime > DateTime.Now).ToList())
                {
                    foreach (Day day in flightNumbertochange.DepartureDays)
                    {
                        if (flight.DepartDateTime.Day.ToString() == day.Name)
                        {
                            safe = true;
                        }
                    }
                    DateTime iterate = new DateTime(2017, 12, 8);
                    while (iterate < new DateTime(2017, 12, 26))
                    {
                        foreach (Day day in flightNumbertochange.DepartureDays)
                        {
                            if (day.Name == iterate.ToString())
                            {
                                if (db.Flights.Where(c => c.FlightNumber.FlightNumberID == flightNumbertochange.FlightNumberID && c.DepartDateTime.Date == iterate.Date).ToList().Count == 0)
                                {
                                    Flight newflight = new Flight(flightNumbertochange.BaseFare, db);
                                    newflight.Cancelled      = false;
                                    newflight.DepartDateTime = iterate + flightNumbertochange.DepartTime;
                                    newflight.Departed       = false;
                                    newflight.FlightNumber   = flightNumbertochange;
                                    db.Flights.Add(newflight);
                                    db.SaveChanges();
                                }
                            }
                        }
                        iterate += new TimeSpan(24, 0, 0);
                    }

                    if (safe)
                    {
                        //flight time might change
                        flight.DepartDateTime += (flightNumbertochange.DepartTime - flight.DepartDateTime.TimeOfDay);
                    }
                    else
                    {
                        flight.Cancelled = true;
                        Int32         maxID                     = db.Reservations.Max(x => x.ReservationID);
                        Reservation   newestReservation         = db.Reservations.Find(maxID);
                        List <Ticket> ReservationWithNewTickets = db.Tickets.Where(x => x.Reservation.ReservationID == newestReservation.ReservationID).ToList();
                        foreach (Ticket ThisTicket in ReservationWithNewTickets)
                        {
                            vm.Email          = ThisTicket.Customer.Email;
                            vm.FirstName      = ThisTicket.Customer.FirstName;
                            vm.LastName       = ThisTicket.Customer.LastName;
                            vm.Flightnumber   = ThisTicket.Flight.FlightNumber.Number;
                            vm.DepartDateTime = ThisTicket.Flight.DepartDateTime;
                        }
                        MailModelsController c         = new MailModelsController();
                        ActionResult         newresult = c.FlightCancelled(vm);
                    }

                    if (flightNumbertochange.BeenDisabled == true)
                    {
                        flight.Cancelled = true;
                        //TODO: DELETE THE FLIGHT BUT FIRST FIND OUT WHO ALL IS ON THE FLIGHT
                    }
                    flight.ActualFare = flightNumbertochange.BaseFare;
                    //TODO: EMAIL THE PEOPLE OF THE CHANGES MY DUDES
                }

                db.Entry(flightNumbertochange).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(flightNumber));
        }