public void ReservationService_AddReservation_ThrowsDbUpdateException()
        {
            //Arrange

            ReservationService reservationService = new ReservationService(_mockReservationsRepository.Object);

            _mockReservationsRepository.Setup(x => x.Insert(It.IsAny <Reservation>())).Throws(new DbUpdateException());
            _mockReservationsRepository.Setup(x => x.Save());

            //Act
            var resultAction = reservationService.AddReservation(_reservationDomainModel).ConfigureAwait(false).GetAwaiter().GetResult();

            //Assert
        }
        public ActionResult ReserverVole(int id)
        {
            reservationvole res = new reservationvole();

            res.vole_id          = id;
            res.users_id         = currentUser.id;
            res.date_reservation = DateTime.Now;
            reservationService.AddReservation(res);
            reservationService.SaveChange();


            IEnumerable <vole> vols = voleservice.GetAllVolsFromNow();

            return(RedirectToAction("Search", vols));
        }
        private void ConfirmReservationButtonOnClick(object sender, EventArgs e)
        {
            ReservationService reservationService = new ReservationService();
            CustomerService    customerService    = new CustomerService();
            Random             rnd      = new Random();
            Customer           customer = new Customer()
            {
                Id   = rnd.Next(1, 999999),
                Name = txtBoxReservationName.Text
            };

            customerService.AddCustomer(customer.Id, customer.Name);
            reservationService.AddReservation(rnd.Next(1, 9999999), table.Number, customer.Id);

            mobileView.ResetTo(new TableView(), "Tafels");
        }
        // Suppression
        public void EnregistrerReservation()
        {
            if (Client != null)
            {
                Reservation.IdentifiantCli = Client.ID;
                if (ID == 0)
                {
                    ID = Srv.AddReservation(Reservation);
                }
                else
                {
                    Srv.UpdateReservation(Reservation);
                }

                EnregistrerChambresReservees();
                ReservationEnregistree?.Invoke(this, EventArgs.Empty);
                NotifyPropertyChanged("Prix");
            }
        }
        public void ReservationService_AddReservation_ReturnsCreateReservationResultModel()
        {
            //Arrange

            ReservationService reservationService = new ReservationService(_mockReservationsRepository.Object);

            _mockReservationsRepository.Setup(x => x.Insert(It.IsAny <Reservation>())).Returns(_reservation);
            _mockReservationsRepository.Setup(x => x.Save());

            //Act
            var resultAction = reservationService.AddReservation(_reservationDomainModel).ConfigureAwait(false).GetAwaiter().GetResult();

            //Assert
            Assert.IsNotNull(resultAction);
            Assert.IsInstanceOfType(resultAction, typeof(CreateReservationResultModel));
            Assert.IsTrue(resultAction.IsSuccessful);
            Assert.IsNull(resultAction.ErrorMessage);
            Assert.AreEqual(_reservation.ProjectionId, resultAction.Reservation.ProjectionId);
            Assert.AreEqual(_reservation.SeatId, resultAction.Reservation.SeatId);
            Assert.AreEqual(_reservation.UserId, resultAction.Reservation.UserId);
        }
Example #6
0
        public ActionResult BookingReservationFinal(string chooseMovie, string chooseCity, string chooseDate, string chooseCinema, string chooseTime, string userEmail, string userPhoneNummber, string userTicket, string movieId)
        {
            Reservation reservation = new Reservation();

            reservation.MovieTitle      = chooseMovie;
            reservation.City            = chooseCity;
            reservation.Date            = chooseDate;
            reservation.Time            = chooseTime;
            reservation.Email           = userEmail;
            reservation.PhoneNummber    = userPhoneNummber;
            reservation.NummberOfTicket = userTicket;
            reservation.MovieId         = movieId;
            reservation.Cinema          = chooseCinema;

            ReservationService.AddReservation(reservation);

            var model = new ReservationFinalViewModel();

            model.Reservation = reservation;

            return(PartialView(model));
        }
        public void ReservationService_AddReservation_RepositoryReturnsNull_ReturnUnseccessfulResultModel()
        {
            //Arrange

            ReservationService reservationService = new ReservationService(_mockReservationsRepository.Object);
            Reservation        reservation        = null;

            _mockReservationsRepository.Setup(x => x.Insert(It.IsAny <Reservation>())).Returns(reservation);
            _mockReservationsRepository.Setup(x => x.Save());


            string expectedMessage = Messages.RESERVATION_CREATION_ERROR;
            //Act
            var resultAction = reservationService.AddReservation(_reservationDomainModel).ConfigureAwait(false).GetAwaiter().GetResult();

            //Assert
            Assert.IsNotNull(resultAction);
            Assert.IsInstanceOfType(resultAction, typeof(CreateReservationResultModel));
            Assert.IsFalse(resultAction.IsSuccessful);
            Assert.IsNotNull(resultAction.ErrorMessage);
            Assert.AreEqual(expectedMessage, resultAction.ErrorMessage);
        }
Example #8
0
        // GET: Home/Reserver/5
        public ActionResult Reserver(int id)
        {
            reservationvole res = new reservationvole();

            res.vole_id          = id;
            res.users_id         = currentUser.id;
            res.date_reservation = DateTime.Now;
            reservationService.AddReservation(res);
            reservationService.SaveChange();

            IEnumerable <reservationvole> mesReservations = reservationService.GetAllReservationByUser(currentUser.id);

            foreach (var reservat in mesReservations)
            {
                int x;
                if (reservat.vole_id.HasValue)
                {
                    x             = reservat.vole_id.Value;
                    reservat.vole = voleservice.GetVoleById(x);
                }
            }

            return(View(mesReservations));
        }
Example #9
0
 public void CreateReservation(Reservation Reservation)
 {
     _service.AddReservation(Reservation);
 }