Ejemplo n.º 1
0
        public void Reserve_RequestCanBeDeclined_Declined()
        {
            //Arange
            Hotel hotel = new Hotel(3);
            IReservationService reservationService = new ReservationService();
            Reservation         reservation1       = new Reservation(1, 3);
            Reservation         reservation2       = new Reservation(2, 5);
            Reservation         reservation3       = new Reservation(1, 9);
            Reservation         reservation4       = new Reservation(0, 15);

            //Act
            bool reservationState1 = reservationService.Reserve(hotel, reservation1);
            bool reservationState2 = reservationService.Reserve(hotel, reservation2);
            bool reservationState3 = reservationService.Reserve(hotel, reservation3);
            bool reservationState4 = reservationService.Reserve(hotel, reservation4);

            //Asert
            bool expected = true;

            Assert.AreEqual(expected, reservationState1);
            Assert.AreEqual(expected, reservationState2);
            Assert.AreEqual(expected, reservationState3);
            expected = false;
            Assert.AreEqual(expected, reservationState4);
        }
        public async Task AddAsync_WhenCalledWithExisting_ShouldUpdate()
        {
            int existingId = 0;

            using (var context = new ApplicationContext(options))
            {
                var reservation = context.Add(
                    new Reservation {
                    GuestNumber = 1, GuestNames = "Guest1"
                }
                    );
                await context.SaveChangesAsync();

                existingId = reservation.Entity.ReservationId;
            }

            using (var context = new ApplicationContext(options))
            {
                var reservationService = new ReservationService(context, localizerMock.Object, emailServiceMock.Object);

                var reservation = await reservationService.AddAsync(
                    new Reservation { ReservationId = existingId, GuestNumber = 2, GuestNames = "Guest1, Guest2" }
                    );

                Assert.True(context.Reservations.Contains(reservation));
                Assert.Equal(2, context.Reservations.Find(reservation.ReservationId).GuestNumber);
                Assert.Equal("Guest1, Guest2", context.Reservations.Find(reservation.ReservationId).GuestNames);
            }
        }
Ejemplo n.º 3
0
        public void DeleteShouldDelete()
        {
            IReservationRepository resRepo   = new ReservationRepoDouble();
            IHostRepository        hostRepo  = new HostRepoDouble();
            IGuestRepository       guestRepo = new GuestRepoDouble();

            ReservationService service = new ReservationService(resRepo, guestRepo, hostRepo);

            Host host = hostRepo.ReadAll()[0];

            Reservation toDelete = new Reservation
            {
                StartDate = new DateTime(2022, 1, 1),
                EndDate   = new DateTime(2022, 1, 8),
                Host      = host,
                ID        = 1
            };

            Reservation copy = new Reservation
            {
                StartDate = new DateTime(2022, 1, 1),
                EndDate   = new DateTime(2022, 1, 8),
                Host      = hostRepo.ReadAll()[0],
                Guest     = guestRepo.ReadAll()[0]
            };

            copy.SetTotal();
            copy.ID = 1;

            var result = service.Delete(toDelete);

            Assert.IsTrue(result.Success);
            Assert.AreEqual(0, service.ViewByHost(host).Value.Count);
            Assert.AreEqual(copy, result.Value);
        }
Ejemplo n.º 4
0
 public ReservationController(MeredithDbContext meredithDbContext, IUserService userService,
                              ReservationService reservationService)
 {
     _meredithDbContext  = meredithDbContext;
     _userService        = userService;
     _reservationService = reservationService;
 }
Ejemplo n.º 5
0
        public void CreateShouldNotAllowNonListedHost()
        {
            IReservationRepository resRepo   = new ReservationRepoDouble();
            IHostRepository        hostRepo  = new HostRepoDouble();
            IGuestRepository       guestRepo = new GuestRepoDouble();

            ReservationService service = new ReservationService(resRepo, guestRepo, hostRepo);

            Host host = new Host
            {
                Email        = "*****@*****.**",
                LastName     = "Duper",
                ID           = "abc-123",
                City         = "Chicago",
                State        = "IL",
                StandardRate = 50M,
                WeekendRate  = 100M
            };

            Guest guest = guestRepo.ReadAll()[0];

            Reservation toAdd = new Reservation
            {
                StartDate = DateTime.Parse("2022,02,02"),
                EndDate   = DateTime.Parse("2022,02,06"),
                Guest     = guest,
                Host      = host
            };

            Result <Reservation> result = service.Create(toAdd);

            Assert.IsFalse(result.Success);
            Assert.IsTrue(result.Messages[0].Contains("host"));
            Assert.IsNull(result.Value);
        }
Ejemplo n.º 6
0
        public void ShouldBeEmptyWithNotFoundMessage()
        {
            IReservationRepository resRepo   = new ReservationRepoDouble();
            IHostRepository        hostRepo  = new HostRepoDouble();
            IGuestRepository       guestRepo = new GuestRepoDouble();

            ReservationService service = new ReservationService(resRepo, guestRepo, hostRepo);

            Host host = new Host
            {
                LastName = "Testy1",
                ID       = "abc-123",
                Email    = "oops",
                City     = "Chicago",
                State    = "IL",
            };

            host.SetRates(50M, 80M);

            Result <List <Reservation> > result = service.ViewByHost(host);

            Assert.IsFalse(result.Success);
            Assert.AreEqual("no reservations found for host", result.Messages[0]);
            Assert.AreEqual(0, result.Value.Count);
        }
Ejemplo n.º 7
0
        public async static Task <Reservation> CreateReservation(int meetingRoomId,
                                                                 int employeeId,
                                                                 DateTime reservationDate,
                                                                 TimeSpan startTime,
                                                                 TimeSpan endTime,
                                                                 List <MovableResource> movableResources,
                                                                 ReservationService reservationService)
        {
            if (!await reservationService.IsWithinOfficeOpenHours(meetingRoomId, startTime, endTime))
            {
                throw new ReservationDomainException("Cannot reserve outside office hours");
            }

            if (!reservationService.IsMeetingRoomAvailable(meetingRoomId, reservationDate, startTime, endTime))
            {
                throw new ReservationDomainException("Meeting room is not available at this time");
            }

            foreach (var resource in movableResources)
            {
                if (await reservationService.IsMeetingRoomHasResource(meetingRoomId, resource.ResourceType))
                {
                    throw new ReservationDomainException($"{resource.ResourceType.ToString()} is already available in the meeting room");
                }
            }
            return(new Reservation(meetingRoomId, employeeId, reservationDate, startTime, endTime, movableResources));
        }
Ejemplo n.º 8
0
        public void ShouldCreateValidReservation(string start, string end)
        {
            IReservationRepository resRepo   = new ReservationRepoDouble();
            IHostRepository        hostRepo  = new HostRepoDouble();
            IGuestRepository       guestRepo = new GuestRepoDouble();

            ReservationService service = new ReservationService(resRepo, guestRepo, hostRepo);

            Host        host  = hostRepo.ReadAll()[0];
            Guest       guest = guestRepo.ReadAll()[0];
            Reservation toAdd = new Reservation
            {
                StartDate = DateTime.Parse(start),
                EndDate   = DateTime.Parse(end),
                Guest     = guest,
                Host      = host
            };

            Result <Reservation> result = service.Create(toAdd);

            Assert.IsTrue(result.Success);
            Assert.AreEqual(2, result.Value.ID);
            Assert.AreEqual(host, result.Value.Host);
            Assert.AreEqual(guest, result.Value.Guest);
            Assert.AreEqual(DateTime.Parse(start), result.Value.StartDate);
            Assert.AreEqual(DateTime.Parse(end), result.Value.EndDate);
        }
        public async Task ReservationService_CreateAsync_Valid()
        {
            // Arrange
            var reservation = new InputModels.Reservation
            {
                AccountId          = Guid.NewGuid(),
                FirstName          = "Test",
                LastName           = "User",
                Notes              = "Test Note",
                ReservationTimeUtc = DateTime.UtcNow,
                RestaurantName     = "Test Restaurant",
                TotalPatrons       = 8
            };

            this._reservationProvider
            .Setup(x => x.GetWithinRange(reservation.AccountId, reservation.ReservationTimeUtc))
            .ReturnsAsync(new Collection <Reservation>());

            var reservationService = new ReservationService(this._reservationProvider.Object);

            // Act
            var result = await reservationService.CreateAsync(reservation);

            Assert.IsNotNull(result);
            Assert.AreEqual(reservation.AccountId, result.AccountId);
            Assert.AreEqual(reservation.FirstName, result.FirstName);
            Assert.AreEqual(reservation.LastName, result.LastName);
            Assert.AreEqual(reservation.Notes, result.Notes);
            Assert.AreEqual(reservation.ReservationTimeUtc, result.ReservationTimeUtc);
            Assert.AreEqual(reservation.RestaurantName, result.RestaurantName);
            Assert.AreEqual(reservation.TotalPatrons, result.TotalPatrons);
        }
Ejemplo n.º 10
0
        public ActionResult GetTodayReservesExcel()
        {
            string fileUrl     = Server.MapPath(@"\Uploads\Reservations.xlsx");
            string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

            return(File(ReservationService.GetTodayReservesExcel(fileUrl), contentType));
        }
        public async Task ReservationService_CreateAsync_Conflicting_Reservation()
        {
            // Arrange
            var reservation = new InputModels.Reservation
            {
                AccountId          = Guid.NewGuid(),
                FirstName          = "Test",
                LastName           = "User",
                Notes              = "Test Note",
                ReservationTimeUtc = DateTime.UtcNow,
                RestaurantName     = "Test Restaurant",
                TotalPatrons       = 8
            };

            this._reservationProvider
            .Setup(x => x.GetWithinRange(reservation.AccountId, reservation.ReservationTimeUtc))
            .ReturnsAsync(new Collection <Reservation>()
            {
                new Reservation(Guid.NewGuid())
            });

            var reservationService = new ReservationService(this._reservationProvider.Object);

            // Act
            var result = await reservationService.CreateAsync(reservation);

            // Assert
            Assert.Fail("Expected exception was not thrown");
        }
Ejemplo n.º 12
0
 public void Update()
 {
     if (KeywordReservation != null)
     {
         ReservationService.UpdateKeywordReservation(KeywordReservation);
     }
     else if (SeriesReservation != null)
     {
         ReservationService.UpdateSeriesReservation(SeriesReservation);
     }
     else if (SlotReservation != null)
     {
         ReservationService.UpdateSlotReservation(SlotReservation);
     }
     else if (SlotReservation2 != null)
     {
         ReservationService.UpdateSlotReservation2(SlotReservation2);
     }
     else if (TimeReservation != null)
     {
         ReservationService.UpdateTimeReservation(TimeReservation);
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Ejemplo n.º 13
0
        // Method for Update Car Rent Screen logic
        public void UpdateReservaion()
        {
            Console.Clear();

            Car car = new Car();
            PrintColorMessage  printColorMessage   = new PrintColorMessage();
            ReservationService reservationServices = new ReservationService();
            Customer           customer            = new Customer();
            Reservation        reservation         = new Reservation();
            Navigation         navigation          = new Navigation();


            Console.Write("Reservation ID:");
            reservation.ReservationID = Convert.ToInt32(Console.ReadLine());

            Console.Write("Customer ID: ");
            reservation.CustomerID = Convert.ToInt32(Console.ReadLine());

            Console.Write("Car Plate: ");
            reservation.CarPlate = Console.ReadLine();

            Console.Write("Start Date: ");
            reservation.StartDate = Convert.ToDateTime(Console.ReadLine());

            Console.Write("End Date: ");
            reservation.EndDate = Convert.ToDateTime(Console.ReadLine());

            Console.Write("Location: ");
            reservation.Location = Console.ReadLine();

            reservationServices.UpdateReservation(reservation);

            printColorMessage.Print(ConsoleColor.Yellow, "Reservation Updated succesffuly!");
            navigation.GoToMenu();
        }
Ejemplo n.º 14
0
        private ReservationService CreateReservationService()
        {
            var StaffIdLogin = Guid.Parse(User.Identity.GetUserId());
            var service      = new ReservationService(StaffIdLogin);

            return(service);
        }
Ejemplo n.º 15
0
        public string GetAllReservations()
        {
            var result   = String.Empty;
            var request  = new GetAllReservationRequest();
            var response = new GetAllReservationResponse();

            ClaimsIdentity identity       = (ClaimsIdentity)User.Identity;
            var            isInternalUser = Convert.ToBoolean(identity.Claims.Where(x => x.Type == "IsInternalUser").First().Value);
            int            userID         = Int32.Parse(identity.Claims.Where(x => x.Type == "UserID").First().Value);

            try
            {
                request.IsInternalUser = isInternalUser;
                request.UserID         = userID;

                ReservationService service = new ReservationService();
                response = service.PerformGetAllReservations(request);
            }
            catch (Exception ex)
            {
                response = new GetAllReservationResponse()
                {
                    MessageString   = ex.Message,
                    MessageStatusID = (byte)EMessageStatus.Exception
                };
                result = JsonConvert.SerializeObject(response);
                return(result);
            }

            result = JsonConvert.SerializeObject(response);
            return(result);
        }
        private void ListItem_Click(object sender, EventArgs e)
        {
            Program            app = Program.GetInstance();
            ReservationService reservationService = app.GetService <ReservationService>("reservations");

            // Get the clicked item
            ListViewItem item = container.SelectedItems[0];

            if (item == null)
            {
                GuiHelper.ShowError("Geen item geselecteerd");
                return;
            }

            // Find the movie
            int         id          = (int)item.Tag;
            Reservation reservation = reservationService.GetReservationById(id);

            if (reservation == null)
            {
                GuiHelper.ShowError("Kon geen reservering vinden voor dit item");
                return;
            }

            // Show screen
            ReservationDetail reservationDetail = app.GetScreen <ReservationDetail>("reservationDetail");

            reservationDetail.SetReservation(reservation);
            app.ShowScreen(reservationDetail);
        }
Ejemplo n.º 17
0
        public string UpdateReservationStatus([FromBody] string req)
        {
            var result   = String.Empty;
            var request  = new UpdateReservationRequest();
            var response = new SaveMenuItemResponse();

            try
            {
                request = JsonConvert.DeserializeObject <UpdateReservationRequest>(req);

                ReservationService service = new ReservationService();
                response = service.PerformUpdateReservationStatus(request);
            }
            catch (Exception ex)
            {
                response = new SaveMenuItemResponse()
                {
                    MessageString   = ex.Message,
                    MessageStatusID = (byte)EMessageStatus.Success
                };
            }

            result = JsonConvert.SerializeObject(response);

            return(result);
        }
Ejemplo n.º 18
0
        public void ShouldReturnSuccessAndList()
        {
            IReservationRepository resRepo   = new ReservationRepoDouble();
            IHostRepository        hostRepo  = new HostRepoDouble();
            IGuestRepository       guestRepo = new GuestRepoDouble();

            ReservationService service = new ReservationService(resRepo, guestRepo, hostRepo);

            Host host = new Host
            {
                LastName = "Testy1",
                ID       = "abc-123",
                Email    = "*****@*****.**",
                City     = "Chicago",
                State    = "IL",
            };

            host.SetRates(50M, 80M);

            Result <List <Reservation> > result = service.ViewByHost(host);

            Assert.IsTrue(result.Success);
            Assert.AreEqual(1, result.Value.Count);
            Assert.AreEqual(410M, result.Value[0].Total);
            Assert.AreEqual(host, result.Value[0].Host);
        }
Ejemplo n.º 19
0
        public async Task <IActionResult> Reservations()
        {
            var reservationService = new ReservationService(new ReservationRepository(_context), new Repository <Room>(_context), _mapper);
            var reservations       = await reservationService.GetAll();

            return(View(new ReservationViewModel(reservations)));
        }
Ejemplo n.º 20
0
        public void AddShouldNotAllowNullHost()
        {
            IReservationRepository resRepo   = new ReservationRepoDouble();
            IHostRepository        hostRepo  = new HostRepoDouble();
            IGuestRepository       guestRepo = new GuestRepoDouble();

            ReservationService service = new ReservationService(resRepo, guestRepo, hostRepo);

            Host host = null;

            Guest guest = guestRepo.ReadAll()[0];

            Reservation toAdd = new Reservation
            {
                StartDate = DateTime.Parse("2022,02,02"),
                EndDate   = DateTime.Parse("2022,02,06"),
                Guest     = guest,
                Host      = host
            };

            Result <Reservation> result = service.Create(toAdd);

            Assert.IsFalse(result.Success);
            Assert.IsTrue(result.Messages[0].Contains("host"));
            Assert.IsNull(result.Value);
        }
        public void ReservationTestSucess()
        {
            var reservationBusinessMock = new Mock <IReservationBusiness>();

            reservationBusinessMock.Setup(
                a => a.Add(It.IsAny <Reservation>(), null)).Returns(true);

            var reservationsExpectancy = new List <Reservation>
            {
                new Reservation()
                {
                    Client = "Jessica Dias Rodrigues", DateStart = DateTime.Now, DateEnd = DateTime.Now.AddDays(2)
                },
                new Reservation()
                {
                    Client = "Cliente Teste", DateStart = DateTime.Now, DateEnd = DateTime.Now.AddDays(10)
                }
            };

            reservationBusinessMock.Setup(a => a.GetList()).Returns(reservationsExpectancy);

            var reservationService = new ReservationService(reservationBusinessMock.Object);
            var reservations       = reservationService.Insert(null, null);

            Assert.NotNull(reservations);
            Assert.True(reservations.Any());

            for (int i = 0; i < reservations.Count; i++)
            {
                Assert.Equal(reservationsExpectancy[i].Client, reservations[i].Client);
                Assert.Equal(reservationsExpectancy[i].DateStart, reservations[i].DateStart);
                Assert.Equal(reservationsExpectancy[i].DateEnd, reservations[i].DateEnd);
            }
        }
Ejemplo n.º 22
0
        public void UpdateShouldAllowOverlapDatesOnResBeingUpdated()
        {
            IReservationRepository resRepo   = new ReservationRepoDouble();
            IHostRepository        hostRepo  = new HostRepoDouble();
            IGuestRepository       guestRepo = new GuestRepoDouble();

            ReservationService service = new ReservationService(resRepo, guestRepo, hostRepo);

            Host  host  = hostRepo.ReadAll()[0];
            Guest guest = guestRepo.ReadAll()[0];

            Reservation toUpdate = new Reservation
            {
                StartDate = new DateTime(2022, 1, 2),
                EndDate   = new DateTime(2022, 1, 9),
                Host      = hostRepo.ReadAll()[0],
                Guest     = guestRepo.ReadAll()[0]
            };

            toUpdate.SetTotal();
            toUpdate.ID = 1;

            var result = service.Update(1, toUpdate);

            Assert.IsTrue(result.Success);
            Assert.AreEqual(toUpdate, result.Value);
            Assert.AreEqual(1, resRepo.ReadByHost(host).Count);
        }
Ejemplo n.º 23
0
        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            IAuthService    authService    = new AuthService("<YourFirebaseApiKey>");
            IUserRepository userRepository = new UserRepository("<YourFirebaseDatabaseURL>", authService);

            authService.UserRepository = userRepository;
            IReservationRepository reservationRepository = new ReservationRepository("<YourFirebaseDatabaseURL>", authService);
            IReservationService    reservationService    = new ReservationService(reservationRepository);

            //ICredentials credentials = new DummyCredentials();
            //credentials.Password = "******";
            //credentials.User = new ClubUser { Email = "*****@*****.**" };
            ICredentials credentials = new SecureCredentials(CrossSecureStorage.Current);


            containerRegistry.RegisterInstance <IAuthService>(authService);
            containerRegistry.RegisterInstance <IReservationRepository>(reservationRepository);
            containerRegistry.RegisterInstance <IReservationService>(reservationService);
            containerRegistry.RegisterInstance <ICredentials>(credentials);

            containerRegistry.RegisterForNavigation <NavigationPage>();
            containerRegistry.RegisterForNavigation <NewReservationPage>();
            containerRegistry.RegisterForNavigation <ReservationsPage>();
            containerRegistry.RegisterForNavigation <ReservationPage>();
            containerRegistry.RegisterForNavigation <LoginPage>();
            containerRegistry.RegisterForNavigation <UserProfilePage>();
        }
Ejemplo n.º 24
0
        public void DeleteShouldNotRunWithNullHost()
        {
            IReservationRepository resRepo   = new ReservationRepoDouble();
            IHostRepository        hostRepo  = new HostRepoDouble();
            IGuestRepository       guestRepo = new GuestRepoDouble();

            ReservationService service = new ReservationService(resRepo, guestRepo, hostRepo);

            Host host = null;

            Reservation toDelete = new Reservation
            {
                StartDate = new DateTime(2022, 1, 1),
                EndDate   = new DateTime(2022, 1, 8),
                Host      = host,
                ID        = 1
            };

            Reservation copy = new Reservation
            {
                StartDate = new DateTime(2022, 1, 1),
                EndDate   = new DateTime(2022, 1, 8),
                Host      = hostRepo.ReadAll()[0],
                Guest     = guestRepo.ReadAll()[0]
            };

            copy.SetTotal();
            copy.ID = 1;

            var result = service.Delete(toDelete);

            Assert.IsFalse(result.Success);
            Assert.IsNull(result.Value);
            Assert.IsTrue(result.Messages[0].Contains("Host"));
        }
Ejemplo n.º 25
0
 public VoleController()
 {
     currentUser        = new user();
     currentUser.id     = 2;
     voleservice        = new VoleService();
     reservationService = new ReservationService();
 }
Ejemplo n.º 26
0
        public void Reserve_AllRequests_Accepted()
        {
            //Arange
            Hotel hotel = new Hotel(3);
            IReservationService reservationService = new ReservationService();
            Reservation         reservation1       = new Reservation(0, 5);
            Reservation         reservation2       = new Reservation(7, 13);
            Reservation         reservation3       = new Reservation(3, 9);
            Reservation         reservation4       = new Reservation(5, 7);
            Reservation         reservation5       = new Reservation(6, 6);
            Reservation         reservation6       = new Reservation(0, 4);

            //Act
            bool reservationState1 = reservationService.Reserve(hotel, reservation1);
            bool reservationState2 = reservationService.Reserve(hotel, reservation2);
            bool reservationState3 = reservationService.Reserve(hotel, reservation3);
            bool reservationState4 = reservationService.Reserve(hotel, reservation4);
            bool reservationState5 = reservationService.Reserve(hotel, reservation5);
            bool reservationState6 = reservationService.Reserve(hotel, reservation6);

            //Asert
            bool expected = true;

            Assert.AreEqual(expected, reservationState1);
            Assert.AreEqual(expected, reservationState2);
            Assert.AreEqual(expected, reservationState3);
            Assert.AreEqual(expected, reservationState4);
            Assert.AreEqual(expected, reservationState5);
            Assert.AreEqual(expected, reservationState6);
        }
        public void CRUD_CreateAndDeleteReservation_CheckSuccress()
        {
            //arrange
            IReservationRepository reservationRepository = new MySqlReservationRepository(Connstr);
            IReservationService    sut = new ReservationService(reservationRepository);
            DateTime startDate         = new DateTime(2019, 04, 25, 10, 00, 00);
            DateTime endDate           = new DateTime(2019, 04, 29, 10, 00, 00);
            bool     isPickedUp        = false;
            int      customerFk        = 1;
            int      carFk             = 1;
            decimal  carPricePerDay    = 30.35m;


            //act
            int reservationCountBefor = sut.GetAllReservation().Count;

            sut.AddReservation(startDate, endDate, isPickedUp, customerFk, carFk, carPricePerDay);
            IReadOnlyList <Reservation> reservations = sut.GetAllReservation();
            int reservationCountAfter = reservations.Count;
            int reservationId         = reservations[reservationCountAfter - 1].ReservationId;

            sut.UpdateReservation(true, reservationId);
            sut.DeleteReservation(reservationId);

            //assert
            Assert.IsTrue(reservationCountBefor < reservationCountAfter);
        }
Ejemplo n.º 28
0
        private void btnCreateReservation_Click(object sender, EventArgs e)
        {
            try
            {                
                ReservationService service = new ReservationService();

                ReservationCreationEntity reservation = new ReservationCreationEntity
                {
                    Reservation = PopulateReservationObject()
                };

                if (service.AddReservation(reservation))
                {
                    MessageBox.Show(reservation.ConfirmMessage, "Reservation Creation Completed");
                    ClearGuestForm();
                    ClearForm();
                }
                else
                {
                    string errorMsg = "";

                    foreach(ValidationError error in reservation.Reservation.Errors)
                    {
                        errorMsg += error.Description + Environment.NewLine;
                    }
                   
                    MessageBox.Show(errorMsg, "Missing Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public override void OnShow()
        {
            Program            app = Program.GetInstance();
            ReservationService reservationService = app.GetService <ReservationService>("reservations");
            UserService        userService        = app.GetService <UserService>("users");
            List <Reservation> reservations       = reservationService.GetReservations();
            User currentUser = userService.GetCurrentUser();

            base.OnShow();

            container.Items.Clear();

            for (int i = 0; i < reservations.Count; i++)
            {
                Reservation reservation = reservations[i];
                Show        show        = reservation.GetShow();
                Movie       movie       = show.GetMovie();
                User        user        = reservation.GetUser();

                // Make sure the user is allowed to see it
                if (!currentUser.admin && currentUser.id != user.id)
                {
                    continue;
                }

                // Create item
                ListViewItem item = new ListViewItem(user.username + " - " + movie.name + " - " + show.startTime.ToString(Program.DATETIME_FORMAT), i);

                item.Tag = reservation.id;
                container.Items.Add(item);
            }
        }
        private void DgvReservation_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            panelDetails.Visible = true;
            string reservationNumber = dgvReservation.SelectedRows[0].Cells[0].Value.ToString();

            ReservationService    service     = new ReservationService();
            ReservationDetailsDTO reservation = service.GetReservationDetails(reservationNumber);

            lblFirstName.Text  = reservation.FirstName;
            lblMiddleName.Text = reservation.MiddleName;
            lblLastName.Text   = reservation.LastName;
            lblAddress.Text    = $"{reservation.StreetAddress}, {reservation.City}, \r\n" +
                                 $"{reservation.ProvinceAbbre}, {reservation.CountryName}," +
                                 $" {reservation.PostalCode}";
            lblHomePhone.Text         = reservation.HomePhone.ToString();
            lblCellPhone.Text         = reservation.CellPhone.ToString();
            lblEmail.Text             = reservation.Email.ToString();
            lblDOB.Text               = reservation.DateOfBirth.ToShortDateString();
            lblCheckIn.Text           = reservation.CheckInDate.ToShortDateString();
            lblCheckOut.Text          = reservation.CheckOutDate.ToShortDateString();
            lblRoomName.Text          = reservation.RoomName.ToString();
            lblRoomNumber.Text        = reservation.RoomNumber.ToString();
            lblAdultNum.Text          = reservation.AdultNumber.ToString();
            lblChildNum.Text          = reservation.ChildNumber.ToString();
            lblBaseRate.Text          = reservation.BaseRate.ToString("C");
            lblTotal.Text             = reservation.Total.ToString("C");
            lblReservationNumber.Text = reservation.ReservationNumber.ToString();
        }
Ejemplo n.º 31
0
 public void OnGetBusinessHours_ReturnSuccess()
 {
     var reservationService = new ReservationService();
     var result=reservationService.GetBusinessHours();
     Assert.IsTrue(result.OperationSuccess);
 }