public ActionResult DeleteConfirmed(int id)
        {
            BookingFile bookingFile = db.BookingFiles.Find(id);

            db.BookingFiles.Remove(bookingFile);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
        public ActionResult Reservation(int?id, [Bind(Include = "ID,CustomerId,TravelId,CreditCardNumber,TotalPrice,TravellersNumber,IsCustomerTraveller,BookingFileState,BookingFileCancellationReason,Insurances")] BookingFile bookingFile, List <int> InsuranceList)
        {
            Travel travel = db.Travels.SingleOrDefault(x => x.ID == id);

            if (ModelState.IsValid)
            {
                //Controle si le nombre de participants (y compris le client) est suffisant
                if (!bookingFile.CheckEnoughTraveller())
                {
                    ReservationActionBeforeRedirect(id);
                    Display("Vous devez absolument avoir 1 participant ou participer vous même au voyage", MessageType.ERROR);
                    return(View());
                }

                // Controle si le nombre de place maximum n'est pas dépassé
                if (!bookingFile.CheckPlaceMaxCapacity())
                {
                    ReservationActionBeforeRedirect(id);
                    Display("Nombre de participant maximum autorisé : 9", MessageType.ERROR);
                    return(View());
                }

                // Controle si le nombre de place est suffisant par rapport au nombre total de place à réserver
                if (!bookingFile.CheckPlaceNumber(travel.SpaceAvailable))
                {
                    ReservationActionBeforeRedirect(id);
                    Display("Nombre de place insuffisant", MessageType.ERROR);
                    return(View());
                }

                // On récupère les assurances par rapport à la liste des assurances selectionnées et on ajoute à la réservation
                if (InsuranceList != null)
                {
                    foreach (int insuranceId in InsuranceList)
                    {
                        bookingFile.Insurances.Add(db.Insurances.Find(insuranceId));
                    }
                }

                db.BookingFiles.Add(bookingFile);
                db.SaveChanges();
                Session["Travellers"] = bookingFile.TravellersNumber;
                Display("Le voyage a été créé. Ajoutez maintenant les participants.");
                if (bookingFile.TravellersNumber > 0)
                {
                    return(RedirectToAction("AddTravellers", new { id = bookingFile.ID })); //Rediriger vers ajout participant
                }

                AddTravellers(bookingFile.ID, new List <Traveller>());
                return(RedirectToAction("Summary", "Reservation", new { id = bookingFile.ID }));
            }
            ReservationActionBeforeRedirect(id);
            return(View());
        }
 public ActionResult Edit([Bind(Include = "ID,CustomerId,TravelId,CreditCardNumber,TotalPrice,TravellersNumber,IsCustomerTraveller,BookingFileState,BookingFileCancellationReason")] BookingFile bookingFile)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bookingFile).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CustomerId = new SelectList(db.Customers, "ID", "PhoneNumber", bookingFile.CustomerId);
     ViewBag.TravelId   = new SelectList(db.Travels, "ID", "ID", bookingFile.TravelId);
     return(View(bookingFile));
 }
        public ActionResult Create([Bind(Include = "CustomerId,TravelId,CreditCardNumber,TotalPrice,TravellersNumber,IsCustomerTraveller,BookingFileState,BookingFileCancellationReason")] BookingFile bookingFile)
        {
            if (ModelState.IsValid)
            {
                db.BookingFiles.Add(bookingFile);
                db.SaveChanges();
                TempData["BookingFileId"] = bookingFile.ID;
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerId = new SelectList(db.Customers, "ID", "PhoneNumber", bookingFile.CustomerId);
            ViewBag.TravelId   = new SelectList(db.Travels, "ID", "ID", bookingFile.TravelId);
            return(View(bookingFile));
        }
        // GET: BackOffice/BookingFiles/Delete/5

        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BookingFile bookingFile = db.BookingFiles.Find(id);

            if (bookingFile == null)
            {
                return(HttpNotFound());
            }
            return(View(bookingFile));
        }
Пример #6
0
        /// <summary>
        /// Get DFO Booking
        /// </summary>
        /// <returns></returns>
        public BookingFile GetBookingFile()
        {
            BookingFile booking = null;

            try
            {
                booking = SDKFactory.GetBookingFile();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(booking);
        }
        // GET: BackOffice/BookingFiles/Edit/5

        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BookingFile bookingFile = db.BookingFiles.Find(id);

            if (bookingFile == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CustomerId = new SelectList(db.Customers, "ID", "PhoneNumber", bookingFile.CustomerId);
            ViewBag.TravelId   = new SelectList(db.Travels, "ID", "ID", bookingFile.TravelId);
            return(View(bookingFile));
        }
Пример #8
0
        public ActionResult AddTravellers(int?id, List <Traveller> travellers)
        {
            BookingFile bookingFile = db.BookingFiles
                                      .Include(x => x.Travel)
                                      .Include(x => x.Insurances)
                                      .Include(x => x.Travellers).SingleOrDefault(x => x.ID == id);

            if (ModelState.IsValid)
            {
                if (bookingFile.IsCustomerTraveller)
                {
                    Customer  user      = (Customer)Session["CUSTOMER"];
                    Traveller traveller = new Traveller
                    {
                        FirstName   = user.FirstName,
                        LastName    = user.LastName,
                        BirthDate   = user.BirthDate,
                        Mail        = user.Mail,
                        Title       = user.Title,
                        PhoneNumber = user.PhoneNumber
                    };
                    travellers.Add(traveller);
                }
                foreach (Traveller t in travellers)
                {
                    var traveller = db.Travellers.SingleOrDefault(x => x.Mail == t.Mail);
                    if (traveller == null)
                    {
                        traveller = t;
                        db.Travellers.Add(traveller);
                        db.SaveChanges();
                    }

                    traveller.BookingFiles.Add(bookingFile);

                    bookingFile.Travellers.Add(traveller);
                    bookingFile.Travel.SpaceAvailable--;
                    db.Entry(bookingFile).State = EntityState.Modified;
                }
                bookingFile.GetTotalPrice();
                db.SaveChanges();
                Display($"Ajout des participants pour le dossier de réservation {bookingFile.ID} effectué avec succès.");
                return(RedirectToAction("Summary", "Reservation", new { id = bookingFile.ID }));
            }
            ViewBag.Titles = getTitles();
            return(View(travellers));
        }
Пример #9
0
        /// <summary>
        /// Get the current booking file from Smart point
        /// </summary>
        /// <returns>Returns the current booking file, if found, else null</returns>
        public static BookingFile GetBookingFile()
        {
            BookingFile bookingFile = null;

            // Retrieve Current TE Control
            TEControl currentTeControl = UIHelper.Instance.CurrentTEControl;

            // Get the GalileoDesktopFactory associated with the current TEControl.
            var galileoDesktopFactory = currentTeControl.Connection.CommunicationFactory as GalileoDesktopFactory;

            if (galileoDesktopFactory != null)
            {
                bookingFile = galileoDesktopFactory.RetrieveCurrentBookingFile();
            }

            return(bookingFile);
        }
        // GET: BackOffice/BookingFiles/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            BookingFile bookingFile = db.BookingFiles
                                      .Include(x => x.Travellers)
                                      .Include(x => x.Customer)
                                      .Include(x => x.Travel.Destination)
                                      .SingleOrDefault(x => x.ID == id);

            if (bookingFile == null)
            {
                return(HttpNotFound());
            }
            return(View(bookingFile));
        }
Пример #11
0
        /// <summary>
        /// Get booking file via traveldata
        /// </summary>
        /// <returns></returns>
        public BookingFile GetBookingFile()
        {
            string config = HostAccess.Instance.ConfigFileName;
            string nm     = HostAccess.Instance.GetDefaultConnection();

            BookingFile bookingFile = null;

            try
            {
                var factory = GetDesktopFactory();
                bookingFile = factory.RetrieveCurrentBookingFile();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(bookingFile);
        }