/// <summary>
 /// Adds a reservation to the current schedule
 /// </summary>
 /// <param name="reserve">Reservation to be added</param>
 /// <returns>true if successful, false otherwise</returns>
 public bool AddReservation(IReservation reserve)
 {
     if (reserve.numberOfGuests <= GetRemainingCapacityForDate(reserve.date)) {
         AddReserveToStorage(reserve);
         return true;
     }
     return false;
 }
 // We can extend this method later to actually store the reserves to a database or file
 private void AddReserveToStorage(IReservation reserve)
 {
     this._reservationsById.Add(reserve.id, reserve);
     if (!this._reservationsByDate.ContainsKey(reserve.date.Date)) {
         this._reservationsByDate.Add(reserve.date.Date, new List<IReservation>());
     }
     this._reservationsByDate[reserve.date.Date].Add(reserve);
 }
        public bool Update(IReservation item)
        {
            IReservation storedItem = Get(item.Id);

            if (storedItem != null)
            {
                storedItem.ClientName = item.ClientName;
                storedItem.Location   = item.Location;
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool Accept(
            IReservation[] reservations, IReservation candidate,
            ITable[] tables, TimeSpan seatingDuration)
        {
            var sameDayReservations = new SameDayReservationFilter()
                                      .Filter(reservations, candidate,
                                              seatingDuration);

            var assignedTables = new BestFitTableAssigner()
                                 .Assign(sameDayReservations, tables);

            var leftTables = tables.Except(assignedTables);

            return(leftTables.Any(t => candidate.CanFit(t)));
        }
Example #5
0
        public void Test1()
        {
            var tables = new[] { new RectangularTable(2), new RectangularTable(2),
                                 new RectangularTable(4), new RectangularTable(4) };

            var reservations = new IReservation[0];

            var candidate = new Reservation(4, new DateTime(2024, 06, 07));

            var actual = new HauteCuisineMaitreD()
                         .Accept(reservations, candidate,
                                 tables, TimeSpan.MaxValue);

            Assert.IsTrue(actual);
        }
Example #6
0
 void IMailbox.Config(IReservation reservation, Guid primaryMailboxGuid, Guid physicalMailboxGuid, TenantPartitionHint partitionHint, Guid mdbGuid, MailboxType mbxType, Guid?mailboxContainerGuid)
 {
     if (TestIntegration.Instance.RemoteExchangeGuidOverride != Guid.Empty)
     {
         bool flag = physicalMailboxGuid != primaryMailboxGuid;
         primaryMailboxGuid  = TestIntegration.Instance.RemoteExchangeGuidOverride;
         physicalMailboxGuid = (flag ? TestIntegration.Instance.RemoteArchiveGuidOverride : TestIntegration.Instance.RemoteExchangeGuidOverride);
     }
     this.reservation          = reservation;
     this.physicalMailboxGuid  = physicalMailboxGuid;
     this.primaryMailboxGuid   = primaryMailboxGuid;
     this.partitionHint        = partitionHint;
     this.mdbGuid              = mdbGuid;
     this.mbxType              = mbxType;
     this.mailboxContainerGuid = mailboxContainerGuid;
 }
Example #7
0
        public IHttpActionResult BuyTicketWithReservation(long id)
        {
            IReservation reservation = reservationRepo.GetReservationyId(id);

            NewTicketWithReservationSummary summary = newTicketWithReservation.New(new TicketWithReservation(id, reservation.ProjectionId,
                                                                                                             reservation.Row, reservation.Column));

            if (summary.IsCreated)
            {
                ITicketDto ticket = ticketRepo.CreateTicket(reservation.ProjectionId, reservation.Row, reservation.Column);

                return(Ok(ticket));
            }

            return(BadRequest(summary.Message));
        }
        public void Test5()
        {
            var reservations = new IReservation[] {
                new Reservation(2, new DateTime(2023, 09, 14))
            };

            var candidate = new Reservation(3, new DateTime(2023, 09, 14));

            var tables = new[] { new RectangularTable(10) };

            var actual = new BoutiqueRestaurantMaitreD()
                         .Accept(reservations, candidate,
                                 tables, TimeSpan.MaxValue);

            Assert.IsTrue(actual);
        }
        public CreateReservation(IReservation reservation)
        {
            InitializeComponent();
            this.reservation = reservation;

            selectEmployeeComboBox.ItemsSource = Controller.GetEmployees();
            selectMachineComboBox.ItemsSource = Controller.GetMachines();
            selectEmployeeComboBox.SelectedIndex = 0;
            selectMachineComboBox.SelectedIndex = 0;

            dayDatePicker.SelectedDate = reservation.Day;
            timeStartDatePicker.SelectedDate = reservation.Start;
            timeEndDatePicker.SelectedDate = reservation.End;
            jamTypeTextBox.Text = reservation.JamType;
            descriptionTextBox.Text = reservation.Description;
        }
Example #10
0
        public void AddReservation(IReservation reservation)
        {
            reservation.Date = DateTime.Now;
            var saving = Repository.GetSavingById(reservation.SavingsId);

            if (reservation.Amount + saving.SavingCurrentAmount > saving.SavingsGoalAmount)
            {
                throw  new Exception("Reservation precedes goal");
            }
            else if (reservation.Amount + saving.SavingCurrentAmount == saving.SavingsGoalAmount)
            {
                saving.State = SavingState.Completed;
                saving.SavingCurrentAmount += reservation.Amount;
                Repository.UpdateSaving(saving);
            }
            Repository.AddReservation(reservation);
        }
Example #11
0
        public async Task <NewTicketSummary> Buy(int id)
        {
            IReservation reservation = await this.reservationRepository.GetById(id);

            DateTime projectionStartdate = await this.projRepo.GetProjectionStartDate(reservation.ProjectionId);

            //DONE: check if time is correctly set.
            if (DateTime.Now.AddMinutes(10) >= projectionStartdate)
            {
                int count = await this.reservationRepository.RemoveAllReservations(reservation.ProjectionId);

                await this.projRepo.IncreaseAvailableSeats(reservation.ProjectionId, count);

                return(new NewTicketSummary(false, StringConstants.ReservationExpired));
            }

            return(await buyTicket.Buy(id));
        }
Example #12
0
        public void Test5() // best fitting configuration
        {
            var tables = new[] { new RectangularTable(3), new RectangularTable(2),
                                 new RectangularTable(4) };

            var reservations = new IReservation[] {
                new Reservation(4, new DateTime(2022, 10, 11)),
                new Reservation(2, new DateTime(2022, 10, 11))
            };

            var candidate = new Reservation(3, new DateTime(2022, 10, 11));

            var actual = new HauteCuisineMaitreD()
                         .Accept(reservations, candidate,
                                 tables, TimeSpan.MaxValue);

            Assert.IsTrue(actual);
        }
        public bool Accept(
            IReservation[] reservations, IReservation candidate,
            ITable[] tables, TimeSpan seatingDuration)
        {
            var sameDayReservations = new SameIntervalReservationFilter()
                                      .Filter(reservations, candidate,
                                              seatingDuration);

            var assignedTables = new AlternativeConfigurationsTableAssigner()
                                 .Assign(sameDayReservations, tables);

            var leftTables = tables.Except(assignedTables);

            var leftTblsGroups = new TableConfigurationsGenerator()
                                 .Generate(leftTables);

            return(leftTblsGroups.Any(t => candidate.CanFit(t)));
        }
Example #14
0
        public async Task <IHttpActionResult> Ticket(int id)
        {
            IReservation reservation = reserveRepo.GetById(id);

            NewCreationSummary summary = await newReservedTicket.New(new Ticket(reservation.ProjectionStartDate, reservation.Movie, reservation.Cinema, reservation.Room, reservation.Row, reservation.Column, reservation.ProjectionId));

            var ticket = ticketRepo.Get(reservation.Row, reservation.Column, reservation.ProjectionId);

            if (summary.IsCreated)
            {
                await projRepo.DecreaseSeatsCount(reservation.ProjectionId);

                return(Ok(ticket));
            }
            else
            {
                return(BadRequest(summary.Message));
            }
        }
        public void PlaceReservation(IReservation PR1)
        {
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();
                string query = "INSERT INTO Reservation (ASPNetUsers_ID, Car_ID, StartDate, EndDate) VALUES (@ASPNetUsers_ID, @Car_ID, @StartDate, @EndDate); ";

                using (SqlCommand command = new SqlCommand(query, conn))
                {
                    command.Parameters.AddWithValue("@Reservation_Number", PR1.Reservation_Number);
                    command.Parameters.AddWithValue("@AspNetUsers_ID", PR1.AspNetUsers_ID);
                    command.Parameters.AddWithValue("@Car_ID", PR1.Car_ID);
                    command.Parameters.AddWithValue("@StartDate", PR1.StartDate);
                    command.Parameters.AddWithValue("@EndDate", PR1.EndDate);

                    command.ExecuteNonQuery();
                }
            }
        }
Example #16
0
        public void Test6() // you should not consider the time
        {
            var tables = new[] { new RectangularTable(3), new RectangularTable(2),
                                 new RectangularTable(4) };

            var reservations = new IReservation[] {
                new Reservation(4, new DateTime(2022, 10, 11)),
                new Reservation(2, new DateTime(2022, 10, 11)),
                new Reservation(3, new DateTime(2022, 10, 11, 17, 00, 00))
            };

            var candidate = new Reservation(3, new DateTime(2022, 10, 11));

            var actual = new HauteCuisineMaitreD()
                         .Accept(reservations, candidate,
                                 tables, TimeSpan.MaxValue);

            Assert.IsFalse(actual);
        }
Example #17
0
        public ICollection <AvailabilityDTO> GetAvailability(IReservation reservation)
        {
            var availableSpacesByDate = new List <AvailabilityDTO>();
            var carPark = carParkRepository.FindCarParkById(reservation.CarParkId);

            for (int i = 0; i <= (reservation.ToDate - reservation.FromDate).Days; i++)
            {
                var reservationDay    = reservation.FromDate.AddDays(i);
                var takenReservations = carPark.Reservations.Where(x => x.FromDate <= reservationDay && x.ToDate >= reservationDay);
                availableSpacesByDate.Add(new AvailabilityDTO()
                {
                    ReservationDate    = reservationDay,
                    SpacesAvailability = FormatAvailabilityString(carPark.AvailableSpaces, takenReservations.Count()),
                    FreeSpaces         = carPark.AvailableSpaces - takenReservations.Count(),
                    Price = parkingPricesService.GetParkingPrice(reservationDay.Month)
                });
            }
            return(availableSpacesByDate);
        }
        private IEnumerable <ITable> AssignAlternativeConfiguration(
            IReservation reservation, IEnumerable <ITable> tables)
        {
            var rectangularTables = tables.Where(t => t is RectangularTable);

            var alternativeConfigs = new TableConfigurationsGenerator()
                                     .Generate(rectangularTables);

            // choose a configuration
            var assignedTbl = AssignTable(reservation, alternativeConfigs);

            if (assignedTbl == null ||
                !(assignedTbl is TableGroup assignedTblGroup))
            {
                return(new ITable[0]);
            }

            // return the selected tables in that configuration
            return(assignedTblGroup);
        }
        public async Task <NewTicketSummary> Buy(int id)
        {
            IReservation reservation = await this.reservationRepository.GetById(id);

            Ticket ticket = new Ticket(
                reservation.ProjectionStartDate,
                reservation.MovieName,
                reservation.CinemaName,
                reservation.RoomNumber,
                reservation.Row,
                reservation.Column,
                reservation.ProjectionId
                );

            await this.reservationRepository.RemoveReservation(reservation.Id);

            await this.ticketRepository.Insert(ticket);

            return(new NewTicketSummary(true, StringConstants.TicketCreated));
        }
Example #20
0
        public IReservation StartRepair(HttpContextBase context, ResourceState resourceState, DateTime actualBeginDateTime, DateTime actualEndDateTime, string notes)
        {
            IReservation repair = null;

            if (Resource.HasState(ResourceState.Online))
            {
                // Create new offline reservation or new limited mode status
                //ResourceState resourceState = rdoStatusOffline.Checked ? ResourceState.Offline : ResourceState.Limited;

                if (resourceState == ResourceState.Offline)
                {
                    // User wants to create new offline reservation

                    // Determine BeginDateTime for repair reservation
                    DateTime beginDateTime, endDateTime;

                    beginDateTime = Resource.GetNextGranularity(actualBeginDateTime, GranularityDirection.Previous);
                    endDateTime   = Resource.GetNextGranularity(actualEndDateTime, GranularityDirection.Next);

                    // Insert the new repair reservation
                    repair = Provider.Scheduler.Reservation.InsertRepair(Resource.ResourceID, CurrentUser.ClientID, beginDateTime, endDateTime, actualBeginDateTime, notes, CurrentUser.ClientID);

                    // Remove invitees and process info that might be in the session
                    context.Session.Remove($"ReservationInvitees#{Resource.ResourceID}");
                    context.Session.Remove($"ReservationProcessInfos#{Resource.ResourceID}");

                    // Set the state into resource table and session object
                    Resources.UpdateState(Resource.ResourceID, ResourceState.Offline, string.Empty);

                    UpdateAffectedReservations(repair);
                }
                else
                {
                    // User sets the tool into limited mode
                    // Set Resource State, txtNotes.Text is saved with Resource table only in limited mode, since limited mode has no reservation record
                    Resources.UpdateState(Resource.ResourceID, ResourceState.Limited, notes);
                }
            }

            return(repair);
        }
        private ITable AssignTable(
            IReservation reservation, IEnumerable <ITable> tables)
        {
            if (!tables.Any())
            {
                return(null);
            }

            var minEmptySeats = tables
                                .Where(t => reservation.CanFit(t))
                                .Min(t => (int?)t.Size - reservation.Quantity);

            if (minEmptySeats == null)
            {
                return(null);
            }

            return(tables
                   .FirstOrDefault(
                       t => t.Size == (minEmptySeats + reservation.Quantity)));
        }
        public void Test1()
        {
            var seatingDuration = TimeSpan.FromHours(2.5);

            var tables = new ITable[] {
                new CircularTable(4),
                new RectangularTable(2), new RectangularTable(2),
                new RectangularTable(2),
                new RectangularTable(1), new RectangularTable(2)
            };

            var reservations = new IReservation[0];

            var candidate = new Reservation(4, new DateTime(2028, 12, 12, 20, 00, 00));

            var actual = new AlternativeTableConfigurationsMaitreD()
                         .Accept(reservations, candidate, tables,
                                 seatingDuration);

            Assert.IsTrue(actual);
        }
Example #23
0
        public int UpdateChargeMultiplierByReservationToolBilling(IReservation rsv)
        {
            // We used to use named queries here which called stored procs to update the ChargeMultiplier, but this was overly
            // complicated. All the stored procs did was just change the ChargeMultiplier so it's a lot simpler to do that here
            // without calling a stored proc, espeically now because we have to get the IToolBilling record anyway to update
            // the UsageFeeCharged amount.

            var tb = GetToolBillingQuery(Utility.InCurrentPeriod(rsv)).FirstOrDefault(x => x.ReservationID == rsv.ReservationID);

            if (tb != null)
            {
                // update the new forgiven pct
                tb.ChargeMultiplier = Convert.ToDecimal(rsv.ChargeMultiplier);

                // calculate the new UsageFeeCharged amount
                CalculateUsageFeeCharged(tb);

                return(1);
            }

            return(0);
        }
        private void InitializeWindowContent()
        {
            reservation = facade.GetReservation(booking.ReservationID);
            contract    = facade.GetCustomer(booking.ContractID);

            reservationNumber.Content = reservation.ID;
            checkInDate.Content       = booking.StartDate.ToLongDateString().ToString();
            checkOutDate.Content      = booking.EndDate.ToLongDateString().ToString();
            contracts.Content         = contract.Name.ToString();
            roomType.Content          = booking.Roomtype.ToString();
            contractsNum.Content      = contract.Phone;
            company.Content           = contract.Company;
            address.Text = contract.Address;

            roomPrice.Content    = booking.ThisPrice;
            roomsprice           = booking.ThisPrice;
            checkOutTime.Content = IClock.Time.GetDateTimeFormats('f')[0].ToString();
            downPayment.Content  = reservation.DownPayment;

            LoadRoomList();
            CalculatePrice();
        }
        /// <summary>
        /// Create a IReservation object for new reservation
        /// </summary>
        /// <param name="reservationModel">reservationModel obj</param>
        /// <returns>IReservation object</returns>
        private IReservation CreateReservation(ReservationModel reservationModel)
        {
            IReservation reservation = null;

            if (reservationModel != null)
            {
                //get IReservation object from reservationservice
                reservation = _reservationService.GetReservationObject();
                //set information the object
                reservationModel.ReservationObj = reservation;
                reservation.CheckInDate         = reservationModel.CheckInDate;
                reservation.ContactNumber       = reservationModel.ContactNumber;
                reservation.CustomerName        = reservationModel.CustomerName;
                reservation.Occupants           = reservationModel.PartyOf;
                foreach (TableModel tb in reservationModel.Table)
                {
                    ITable tableObj = _tableService.GetTableObject();
                    tableObj.Id           = tb.TableID;
                    tableObj.MaxOccupancy = tb.TableOccupancy;
                    _reservationService.SetTableObjectOnReservation(tableObj, reservation);
                }
            }
            return(reservation);
        }
        internal IReservation UpdateReservation(IReservation reservation)
        {
            connect();
            SQLiteCommand cmd = new SQLiteCommand("Update Reservation Set PAYMENT=:PAYMENT,DOWNPAYMENT=:DOWNPAYMENT,RSTATUS=:RSTATUS Where RESERVATIONID=:RESERVATIONID", sqlCon);

            cmd.Parameters.AddWithValue("RESERVATIONID", reservation.ID);
            cmd.Parameters.AddWithValue("PAYMENT", reservation.Payment);
            cmd.Parameters.AddWithValue("DOWNPAYMENT", reservation.DownPayment);
            cmd.Parameters.AddWithValue("RSTATUS", reservation.RStatus.ToString());

            try
            {
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception("Reservation with ID: " + reservation.ID + " could not be updated!\n" + ex.Message);
            }
            finally
            {
                disconnect();
            }
            return(GetReservation(reservation.ID));
        }
Example #27
0
        public IReservation EndRepair(DateTime now)
        {
            IReservation repair = null;

            if (Resource.HasState(ResourceState.Offline))
            {
                var rip = Reservations.GetRepairInProgress(Resource);

                if (rip != null)
                {
                    repair = Provider.Scheduler.Reservation.GetReservation(rip.ReservationID);

                    if (repair != null)
                    {
                        if (Resource.IsSchedulable)
                        {
                            // Set Scheduled EndDateTime = next gran boundary in future
                            var endDateTime = Resource.GetNextGranularity(now, GranularityDirection.Next);

                            Provider.Scheduler.Reservation.UpdateRepair(repair.ReservationID, endDateTime, repair.Notes, CurrentUser.ClientID);

                            // End the repair reservation now
                            var util = Reservations.Create(Provider, now);
                            util.End(repair, now, CurrentUser.ClientID);

                            UpdateAffectedReservations(repair);
                        }
                    }
                }
            }

            // Set Resource State
            Resources.UpdateState(Resource.ResourceID, ResourceState.Online, string.Empty);

            return(repair);
        }
Example #28
0
        public IReservation UpdateRepair(DateTime actualEndDateTime, string notes)
        {
            IReservation result = null;

            if (Resource.HasState(ResourceState.Offline))
            {
                // Determine BeginDateTime for repair reservation
                DateTime endDateTime;

                var rip = Reservations.GetRepairInProgress(Resource);

                if (rip != null)
                {
                    IReservation repair = Provider.Scheduler.Reservation.GetReservation(rip.ReservationID);

                    if (repair != null)
                    {
                        endDateTime = Resource.GetNextGranularity(actualEndDateTime, GranularityDirection.Next);

                        // Modify existing repair reservation
                        result = Provider.Scheduler.Reservation.UpdateRepair(repair.ReservationID, endDateTime, notes, CurrentUser.ClientID);

                        // result has the modified end datetime, so affected reservations will be updated

                        UpdateAffectedReservations(result);
                    }
                }
            }
            else
            {
                // modifying limited mode, only StateNotes is modifiable in this case
                Resources.UpdateState(Resource.ResourceID, ResourceState.Limited, notes);
            }

            return(result);
        }
Example #29
0
 public void AddReservation(IReservation reservation)
 {
     throw new NotImplementedException();
 }
 public HomeController(IReservation reservation)
 {
     this.reservation = reservation;
 }
Example #31
0
 void IMailbox.Config(IReservation reservation, Guid primaryMailboxGuid, Guid physicalMailboxGuid, TenantPartitionHint partitionHint, Guid mdbGuid, MailboxType mbxType, Guid?mailboxContainerGuid)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Fabrique le IReservation de la QuidditchDataAccessLayerBaseDeDonnees
 /// </summary>
 /// <param name="reservation">Reservation de la QuidditchBusinessLayer</param>
 /// <returns>Le reservation pour la QuidditchDataAccessLayerBaseDeDonnees</returns>
 public static QuidditchDataAccessLayerBaseDeDonnees.IReservation FabriquerReservation(IReservation reservation)
 {
     return new ReservationDal(reservation.Identifiant, reservation.Prix, reservation.Place);
 }
 public ReservationController(IConfiguration configuration)
 {
     _reservationRepo = new ReservationRepository(configuration);
 }
 // This provides a seam in the factory where I can prime the factory with the user it will then cough up. (for test code)
 public static void SetReservation(IReservation aReservation)
 {
     _reservation = aReservation;
 }
 /// <summary>
 /// Permet d'ajouter une réservation
 /// </summary>
 /// <param name="reservation">Instance de la réservation à ajouter</param>
 public void AddReservation(IReservation reservation, int idMatch)
 {
     if (_dalProxy.AddReservation(FabriqueReservation.FabriquerReservation(reservation), idMatch) == -1)
     {
         throw new MatchOverbookException();
     }
 }
 private ReservationModel ReservationToModel(IReservation r)
 {
     return new ReservationModel { date = r.date, name = r.name, numberOfGuests = r.numberOfGuests, id = r.id };
 }
 /// <summary>
 /// Permet d'insérer une réservation en base de données
 /// </summary>
 /// <param name="reservation">La réservation à insérer</param>
 /// <returns>Retourne un entier qui est le résultat de la requête</returns>
 public int InsertReservation(IReservation reservation, int idMatch)
 {
     int result = 0;
     using (SqlConnection sqlConnection = new SqlConnection(_connectionString))
     {
         SqlCommand sqlCommand = new SqlCommand(SqlQuery.INSERT_RESERVATION);
         SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
         sqlCommand.CommandType = CommandType.Text;
         sqlCommand.Connection = sqlConnection;
         sqlCommand.Parameters.AddWithValue("@place", reservation.Place);
         sqlCommand.Parameters.AddWithValue("@prix", reservation.Prix);
         sqlCommand.Parameters.AddWithValue("@match_id_ref", idMatch);
         sqlCommand.Parameters.AddWithValue("@spectateur_id_ref", 0);
         sqlConnection.Open();
         result = sqlCommand.ExecuteNonQuery();
     }
     return result;
 }
 public bool checkOutReservationToDb(IReservation theReservation)
 {
     try
     {
         ds = new DataSet();
         string sql = "SELECT * From Reservations";
         da = new SqlDataAdapter(sql, con);
         da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
         cb = new SqlCommandBuilder(da); //Generates
         da.Fill(ds, "ReservationsData");
         DataRow findRow = ds.Tables["ReservationsData"].Rows.Find(theReservation.ReservationId);
         if (findRow != null)
         {
             findRow[12] = "checked out";
         }
         da.Update(ds, "ReservationsData"); //remove row from database table
     }
     catch (System.Exception excep)
     {
         MessageBox.Show(excep.Message);
         if (getConnection().ToString() == "Open")
             closeConnection();
         Application.Exit();
     }
     return true;
 }
        /// <summary>
        /// Constructeur par copie d'une réservation
        /// </summary>
        /// <param name="reservationToCopy">Instance de Réservation à copier</param>
        public Reservation(IReservation reservationToCopy)
            : this(reservationToCopy.Identifiant, reservationToCopy.Prix, reservationToCopy.Place)
        {

        }
 /// <summary>
 /// Fabrique le IReservation de la QuidditchBusinessLayer
 /// </summary>
 /// <param name="reservation">Reservation de la QuidditchWebServices</param>
 /// <returns>Le reservation pour la QuidditchBusinessLayer</returns>
 public static QuidditchBusinessLayer.IReservation FabriquerReservation(IReservation reservation)
 {
     return new ReservationBusiness(reservation.Identifiant, reservation.Prix, reservation.Place);
 }
Example #41
0
 /// <summary>
 /// Permet d'ajouter une réservation
 /// </summary>
 /// <param name="reservation">Réservation à ajouter</param>
 /// <param name="idMatch">Identifiant du match</param>
 /// <returns>0 si l'ajout s'est fait correctement, -1 si non</returns>
 public int AddReservation(IReservation reservation, int idMatch)
 {
     return DalManager.AddReservation(reservation, idMatch);
 }
 /// <summary>
 /// Permet d'ajouter un match en base
 /// </summary>
 /// <param name="match">Match à ajouter</param>
 /// <param name="idMatch">Identifiant du match</param>
 /// <returns>Entier indiquant le résultat</returns>
 public int AddReservation(IReservation reservation, int idMatch)
 {
     DataTable numberPlace = DataAccess.FindNumberPlaceCanBeReservedForOnMatch(idMatch);
     if (numberPlace.Rows.Count > 0)
     {
         int numberPlaceRestant = (int) numberPlace.Rows[0]["numbrePlaceRestante"];
         if (numberPlaceRestant <= 0)
         {
             return -1;
         }
     }
     return DataAccess.InsertReservation(reservation, idMatch);
 }
Example #43
0
 public DiversHotelController(IReservation <Reservation> RRebository)
 {
     db = RRebository;
 }
        public void addNewReservationToDb(IReservation theReservation)
        {
            try
            {
                DataSet ds = new DataSet();
                string sql = "SELECT * From Reservations";
                SqlDataAdapter da = new SqlDataAdapter(sql, con);
                SqlCommandBuilder cb = new SqlCommandBuilder(da);  //Generates
                da.Fill(ds, "ReservationsData");
                totUsers = ds.Tables["ReservationsData"].Rows.Count;
                DataRow dRow = ds.Tables["ReservationsData"].NewRow();
                dRow[0] = theReservation.ReservationId;
                dRow[1] = theReservation.Guest.GuestId;
                dRow[2] = theReservation.Room.RoomId;
                dRow[3] = theReservation.CheckIn;
                dRow[4] = theReservation.CheckOut;
                dRow[5] = theReservation.NoOfPets;
                dRow[6] = theReservation.TotalPrice;
                dRow[7] = theReservation.AdditionalInfo;
                dRow[8] = theReservation.NoOfGuests;
                dRow[9] = theReservation.NoOfAdults;
                dRow[10] = theReservation.NoOfChildren;
                dRow[11] = theReservation.DateBooked;
                dRow[12] = theReservation.Status.Trim();
                dRow[13] = theReservation.CreditCard.CardNo;

                ds.Tables["ReservationsData"].Rows.Add(dRow);
                da.Update(ds, "ReservationsData");
            }
            catch (System.Exception excep)
            {
                if (con.State.ToString() == "Open")
                    con.Close();
                Application.Exit();
                //Environment.Exit(0); //Force the application to close
            }
        }