Пример #1
0
 public void When(BookingCreated evt)
 {
     Id = evt.Id;
     BookableShowId = evt.BookableShowId;
     BookedSeats = evt.BookedSeats;
     Created = evt.Created;
 }
Пример #2
0
 public BookingCreated(BookingId id, BookableShowId bookableShowId, List<Seat> bookedSeats, DateTime created)
 {
     Id = id;
     BookableShowId = bookableShowId;
     BookedSeats = bookedSeats;
     Created = created;
 }
Пример #3
0
        public TestBase()
        {
            BookingId = BookingId.New;
            Resolver  = EventFlowOptions.New
                        .ConfigureBookingDomain()
                        .CreateResolver();

            AggregateStore = Resolver.Resolve <IAggregateStore>();
        }
Пример #4
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (reservation_ != null)
            {
                hash ^= Reservation.GetHashCode();
            }
            if (BookingId.Length != 0)
            {
                hash ^= BookingId.GetHashCode();
            }
            if (dateRangePrior_ != null)
            {
                hash ^= DateRangePrior.GetHashCode();
            }
            if (roomTypePrior_ != null)
            {
                hash ^= RoomTypePrior.GetHashCode();
            }
            if (NumberAdultsPrior != 0)
            {
                hash ^= NumberAdultsPrior.GetHashCode();
            }
            if (NumberChildrenPrior != 0)
            {
                hash ^= NumberChildrenPrior.GetHashCode();
            }
            if (priceEstimatePrior_ != null)
            {
                hash ^= PriceEstimatePrior.GetHashCode();
            }
            if (dateRangeLatter_ != null)
            {
                hash ^= DateRangeLatter.GetHashCode();
            }
            if (roomTypeLatter_ != null)
            {
                hash ^= RoomTypeLatter.GetHashCode();
            }
            if (NumberAdultsLatter != 0)
            {
                hash ^= NumberAdultsLatter.GetHashCode();
            }
            if (NumberChildrenLatter != 0)
            {
                hash ^= NumberChildrenLatter.GetHashCode();
            }
            if (priceEstimateLatter_ != null)
            {
                hash ^= PriceEstimateLatter.GetHashCode();
            }
            hash ^= tagsPrior_.GetHashCode();
            hash ^= tagsLatter_.GetHashCode();
            return(hash);
        }
Пример #5
0
        /// <summary>
        /// Return a XML representation of this object.
        /// </summary>
        /// <param name="CustomSetServiceAuthorisationRequestSerializer">A delegate to serialize custom set EVSE busy status request XML elements.</param>
        /// <param name="CustomMeterReportSerializer">A delegate to serialize custom MeterReport XML elements.</param>
        public XElement ToXML(CustomXMLSerializerDelegate <SetServiceAuthorisationRequest> CustomSetServiceAuthorisationRequestSerializer = null,
                              CustomXMLSerializerDelegate <MeterReport> CustomMeterReportSerializer = null)
        {
            var XML = new XElement(eMIPNS.Authorisation + "eMIP_ToIOP_SetServiceAuthorisationRequest",

                                   TransactionId.HasValue
                              ? new XElement("transactionId", TransactionId.ToString())
                              : null,

                                   new XElement("partnerIdType", PartnerId.Format.AsText()),
                                   new XElement("partnerId", PartnerId.ToString()),

                                   new XElement("operatorIdType", OperatorId.Format.AsText()),
                                   new XElement("operatorId", OperatorId.ToString()),

                                   new XElement("EVSEIdType", EVSEId.Format.AsText()),
                                   new XElement("EVSEId", EVSEId.ToString()),

                                   new XElement("userIdType", UserId.Format.AsText()),
                                   new XElement("userId", UserId.ToString()),

                                   new XElement("requestedServiceId", RequestedServiceId.ToString()),
                                   new XElement("authorisationValue", AuthorisationValue.ToString()),
                                   new XElement("intermediateCDRRequested", IntermediateCDRRequested ? "1" : "0"),

                                   PartnerServiceSessionId.HasValue
                              ? new XElement("serviceSessionId", PartnerServiceSessionId.ToString())
                              : null,

                                   UserContractIdAlias.HasValue
                              ? new XElement("userContractIdAlias", UserContractIdAlias.ToString())
                              : null,

                                   MeterLimits.SafeAny()
                              ? new XElement("meterLimitList", MeterLimits.Select(meterreport => meterreport.ToXML(CustomMeterReportSerializer: CustomMeterReportSerializer)))
                              : null,

                                   Parameter.IsNotNullOrEmpty()
                              ? new XElement("parameter", Parameter)
                              : null,

                                   BookingId.HasValue
                              ? new XElement("bookingId", BookingId.ToString())
                              : null,

                                   SalePartnerBookingId.HasValue
                              ? new XElement("salePartnerBookingId", SalePartnerBookingId.ToString())
                              : null

                                   );


            return(CustomSetServiceAuthorisationRequestSerializer != null
                       ? CustomSetServiceAuthorisationRequestSerializer(this, XML)
                       : XML);
        }
        protected async override Task <AccountRoot> Apply(BookPaymentCommand command, CancellationToken cancellationToken)
        {
            AggregateRoot.BookPayment(
                BookingId.FromGuid(command.AccountItemDto.BookingId),
                Payment.FromDecimal(command.AccountItemDto.Amount, AggregateRoot.Currency.Value),
                BookingDate.FromDate(command.AccountItemDto.Date),
                Description.FromString(command.AccountItemDto.Description));

            return(await Task.FromResult(AggregateRoot));
        }
Пример #7
0
 public Driver(String baseUrl, String username, String password)
 {
     _baseUrl       = baseUrl;
     _token         = this.AccessToken(username, password);
     _content       = null;
     _response      = null;
     _nextBooking   = null;
     _lastBookingId = null;
     _lastBooking   = null;
 }
Пример #8
0
 public void PlaceBid(TenantId tenantId, BookingId bookingId, TherapistId therapistId, DateTime?proposedTime)
 {
     using (var uow = _unitOfWorkFactory.CreateSession())
     {
         // Get booking, bid and commit
         var booking = uow.GetRepository <IBookingWriteRepository>().Get(bookingId);
         booking.Bid(therapistId, proposedTime);
         uow.Commit();
     }
 }
        public void BookingId_ValidGuid_Created()
        {
            //Arrange
            var guid = Guid.Parse("dca2b44e-6ea7-4812-8c2f-ca772512ca01");

            //Act
            var bookingId = BookingId.FromGuid(guid);

            //Assert
            Assert.AreEqual(guid, bookingId.Value);
        }
Пример #10
0
 public void ConfirmBid(TenantId tenantId, BookingId bookingId, TherapistId therapistId)
 {
     using (var uow = _unitOfWorkFactory.CreateSession())
     {
         // Get booking, open for tender and commit
         var booking   = uow.GetRepository <IBookingWriteRepository>().Get(bookingId);
         var therapist = booking.TherapistBookings.First(t => t.TherapistId == therapistId);
         therapist.Confirm();
         uow.Commit();
     }
 }
Пример #11
0
        public SelectJourneysCommandHandlerTests()
        {
            _bookingId = BookingId.New;
            _resolver  = EventFlowOptions.New
                         .ConfigureBookingDomain()
                         .ConfigureBookingCommands()
                         .ConfigureBookingCommandHandlers()
                         .CreateResolver();

            _commandBus     = _resolver.Resolve <ICommandBus>();
            _aggregateStore = _resolver.Resolve <IAggregateStore>();
        }
Пример #12
0
        public ReadBooking(DbBooking booking)
        {
            _innerBooking = booking;
            BookingId     = new BookingId(_innerBooking.BookingId);
            CustomerId    = new CustomerId(_innerBooking.CustomerId);

            TherapistBookings = _innerBooking
                                .TherapistBookings
                                .Select(tb => (IReadTherapistBooking) new ReadTherapistBooking(tb))
                                .ToList()
                                .AsReadOnly();
        }
Пример #13
0
 public Task <IReadBooking> GetBookingAsync(
     TenantId tenantId,
     BookingId bookingId,
     bool includeTherapists,
     CancellationToken cancellationToken)
 {
     return(_bookingReadRepository
            .GetBookingAsync(
                tenantId,
                bookingId,
                includeTherapists,
                cancellationToken));
 }
Пример #14
0
 public string[] ToArray()
 {
     return(new string[]
     {
         BookingId.ToString(),
         RegistrationNumber,
         VehicleType,
         Customer,
         Cost.ToString(),
         Rented.ToString(),
         Returned == DateTime.MinValue ?
         String.Empty : Returned.ToString()
     });
 }
Пример #15
0
 public string[] ToArray()
 {
     return(new string[]
     {
         Customer,
         Title,
         Genre,
         Rented.ToString(),
         Returned == DateTime.MinValue ? String.Empty : Returned.ToString(),
         Cost.ToString(),
         BookingId.ToString(),
         CustomerId.ToString()
     });
 }
Пример #16
0
        public TestBase()
        {
            var services = new ServiceCollection();

            ConfigurationRootCreator.Create(services);

            BookingId = BookingId.New;
            Resolver  = EventFlowOptions.New
                        .UseServiceCollection(services)
                        .RegisterModule <BookingDomainModule>()
                        .RegisterServices(r => r.Register <IDbContextProvider <EventStoreContext>, FakedEventStoreContextProvider>())
                        .CreateResolver();

            AggregateStore = Resolver.Resolve <IAggregateStore>();
        }
Пример #17
0
 public async Task <int?> GetBookingStatus(BookingId id, FacilityId facilityId)
 {
     return(await connection.ExecuteScalarAsync <int?>(
                @"SELECT
             b.status
         FROM
             booking.bookings b
         WHERE
             b.booking_id = @Id AND
             b.facility_id = @FacilityId",
                new
     {
         Id = id.Value,
         FacilityId = facilityId.Value
     }));
 }
Пример #18
0
        public override int GetHashCode()
        {
            int hashCode = 1444669335;

            hashCode = hashCode * -1521134295 + Id.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <Booking> .Default.GetHashCode(Booking);

            hashCode = hashCode * -1521134295 + BookingId.GetHashCode();
            hashCode = hashCode * -1521134295 + Score.GetHashCode();
            hashCode = hashCode * -1521134295 + _score.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Comment);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(_comment);

            return(hashCode);
        }
Пример #19
0
        public void ChangeBooking_ValidParams_BookingAddedToAccount()
        {
            //Arrange
            var bookingIdGuid = Guid.Parse("b9c18f4d-8f11-408d-be7c-c7f022abefb2");
            var bookingId     = BookingId.FromGuid(bookingIdGuid);
            var payment       = Payment.FromDecimal(100.00m, "EUR");
            var bookingDate   = BookingDate.FromString("2020-09-26");
            var description   = Description.FromString("My payment");

            var accountIdGuid = Guid.Parse("9ccf4aa8-cd1e-4044-a183-464c8a8730ec");
            var account       = AccountRoot.Create(
                AccountId.FromGuid(accountIdGuid),
                UserId.FromGuid(Guid.Parse("13f172e2-7189-4506-b232-894bafcd4449")),
                Period.FromMonth(2020, 9),
                CurrencyCode.FromString("EUR"));

            account.BookPayment(bookingId, payment, bookingDate, description);

            var changedPayment     = Payment.FromDecimal(200.00m, "EUR");
            var changedBookingDate = BookingDate.FromString("2020-09-20");
            var changedDescription = Description.FromString("My payment changed");

            //Act
            account.ChangeBooking(bookingId, changedPayment, changedBookingDate, changedDescription);

            //Assert
            Assert.IsNotNull(account.Bookings);
            Assert.IsNotNull(account.Bookings[0]);
            var booking = account.Bookings[0];

            Assert.AreEqual(bookingIdGuid, booking.Id.Value);
            Assert.AreEqual(200.00m, booking.Payment.Amount);
            Assert.AreEqual("EUR", booking.Payment.CurrencyCode);
            Assert.AreEqual(DateTime.Parse("2020-09-20"), booking.Date.Value);
            Assert.AreEqual("My payment changed", booking.Description.Value);
            Assert.AreEqual(3, account.GetChanges().Count);
            Assert.AreEqual(typeof(V1.BookingChanged), account.GetChanges()[2].GetType());
            var @event = account.GetChanges()[2] as V1.BookingChanged;

            Assert.AreEqual(accountIdGuid, @event.AccountId);
            Assert.AreEqual(bookingIdGuid, @event.BookingId);
            Assert.AreEqual(200.00m, @event.Amount);
            Assert.AreEqual("EUR", @event.CurrencyCode);
            Assert.AreEqual(DateTime.Parse("2020-09-20"), @event.Date);
            Assert.AreEqual("My payment changed", @event.Description);
        }
Пример #20
0
        public void BookPayment_PaymentDateOutsidePeriod_InvalidEntityStateException()
        {
            //Arrange
            var bookingIdGuid = Guid.Parse("b9c18f4d-8f11-408d-be7c-c7f022abefb2");
            var bookingId     = BookingId.FromGuid(bookingIdGuid);
            var payment       = Payment.FromDecimal(100.00m, "EUR");
            var bookingDate   = BookingDate.FromString("2020-01-01");
            var description   = Description.FromString("My payment");

            var accountIdGuid = Guid.Parse("9ccf4aa8-cd1e-4044-a183-464c8a8730ec");
            var account       = AccountRoot.Create(
                AccountId.FromGuid(accountIdGuid),
                UserId.FromGuid(Guid.Parse("13f172e2-7189-4506-b232-894bafcd4449")),
                Period.FromMonth(2020, 9),
                CurrencyCode.FromString("EUR"));

            //Act & Assert
            Assert.Throws <InvalidEntityState>(() => account.BookPayment(bookingId, payment, bookingDate, description));
        }
Пример #21
0
        public void Cancel(TenantId tenantId, BookingId bookingId, CustomerId customerId, string reason)
        {
            using (var uow = _unitOfWorkFactory.CreateSession())
            {
                // Get booking, open for tender and commit
                var booking = uow.GetRepository <IBookingWriteRepository>().Get(bookingId);

                // Sanity check: Owner of booking must match specified customer
                if (booking.CustomerId != customerId)
                {
                    throw new ArgumentException(
                              "Booking is owned by different customer.",
                              nameof(customerId));
                }

                booking.Cancel(reason);
                uow.Commit();
            }
        }
Пример #22
0
        public void AcceptBid(TenantId tenantId, BookingId bookingId, CustomerId customerId, TherapistId therapistId)
        {
            using (var uow = _unitOfWorkFactory.CreateSession())
            {
                // Get booking, open for tender and commit
                var booking = uow.GetRepository <IBookingWriteRepository>().Get(bookingId);

                // Sanity check: Owner of booking must match specified customer
                if (booking.CustomerId != customerId)
                {
                    throw new ArgumentException(
                              "Booking is owned by different customer.",
                              nameof(customerId));
                }

                // Find the associated therapist for this booking, accept bid then commit
                var therapist = booking.TherapistBookings.First(t => t.TherapistId == therapistId);
                therapist.Accept();
                uow.Commit();
            }
        }
Пример #23
0
        public void Close_StateClosedAmountSumOfBookings()
        {
            //Arrange
            var idGuid    = Guid.Parse("051f8160-ce43-4ac0-b8c2-09707c2bcda3");
            var id        = AccountId.FromGuid(idGuid);
            var ownerGuid = Guid.Parse("4bc0c0e9-7181-45e4-934d-e91c0e7bbd75");
            var ownerId   = UserId.FromGuid(ownerGuid);
            var period    = Period.FromMonth(2020, 9);
            var currency  = CurrencyCode.FromString("EUR");

            var account = AccountRoot.Create(id, ownerId, period, currency);

            account.BookPayment(
                BookingId.FromGuid(Guid.Parse("9d8d8a72-59a0-4a1b-8b86-94960df74586")),
                Payment.FromDecimal(10.00m, "EUR"),
                BookingDate.FromString("2020-09-01"),
                Description.FromString("Booking1"));

            account.BookPayment(
                BookingId.FromGuid(Guid.Parse("cbf7333e-3a7a-4bf9-ac85-4bdb22f7afb0")),
                Payment.FromDecimal(5.10m, "EUR"),
                BookingDate.FromString("2020-09-02"),
                Description.FromString("Booking2"));

            account.BookPayment(
                BookingId.FromGuid(Guid.Parse("07a94bd6-ae33-4765-9d1d-5257297e7ed0")),
                Payment.FromDecimal(8.43m, "EUR"),
                BookingDate.FromString("2020-09-03"),
                Description.FromString("Booking3"));

            //Act
            account.Close();

            //Assert
            Assert.AreEqual(AccountState.AccountStateEnum.Closed, account.State.Value);
            Assert.IsTrue(account.GetChanges().Last() is V1.AccountClosed);
            var @event = account.GetChanges().Last() as V1.AccountClosed;

            Assert.AreEqual(idGuid, @event.AccountId);
        }
Пример #24
0
        /// <summary>
        /// Returns true if BookingResponse instances are equal
        /// </summary>
        /// <param name="other">Instance of BookingResponse to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(BookingResponse other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     DutyId == other.DutyId ||
                     DutyId != null &&
                     DutyId.Equals(other.DutyId)
                     ) &&
                 (
                     BookingId == other.BookingId ||
                     BookingId != null &&
                     BookingId.Equals(other.BookingId)
                 ) &&
                 (
                     AllocatePersonId == other.AllocatePersonId ||
                     AllocatePersonId != null &&
                     AllocatePersonId.Equals(other.AllocatePersonId)
                 ) &&
                 (
                     MasterDutyId == other.MasterDutyId ||
                     MasterDutyId != null &&
                     MasterDutyId.Equals(other.MasterDutyId)
                 ) &&
                 (
                     SlaveDutyId == other.SlaveDutyId ||
                     SlaveDutyId != null &&
                     SlaveDutyId.Equals(other.SlaveDutyId)
                 ));
        }
Пример #25
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                var hashCode = 41;
                // Suitable nullity checks etc, of course :)
                if (BookingRequestId != null)
                {
                    hashCode = hashCode * 59 + BookingRequestId.GetHashCode();
                }
                if (BookingId != null)
                {
                    hashCode = hashCode * 59 + BookingId.GetHashCode();
                }
                if (AgencyId != null)
                {
                    hashCode = hashCode * 59 + AgencyId.GetHashCode();
                }

                hashCode = hashCode * 59 + Cost.GetHashCode();
                return(hashCode);
            }
        }
Пример #26
0
        public void DeleteBooking_NonExistingBookingId_InvalidOperationException()
        {
            //Arrange
            var bookingIdGuid = Guid.Parse("b9c18f4d-8f11-408d-be7c-c7f022abefb2");
            var bookingId     = BookingId.FromGuid(bookingIdGuid);
            var payment       = Payment.FromDecimal(100.00m, "EUR");
            var bookingDate   = BookingDate.FromString("2020-09-26");
            var description   = Description.FromString("My payment");

            var accountIdGuid = Guid.Parse("9ccf4aa8-cd1e-4044-a183-464c8a8730ec");
            var account       = AccountRoot.Create(
                AccountId.FromGuid(accountIdGuid),
                UserId.FromGuid(Guid.Parse("13f172e2-7189-4506-b232-894bafcd4449")),
                Period.FromMonth(2020, 9),
                CurrencyCode.FromString("EUR"));

            account.BookPayment(bookingId, payment, bookingDate, description);

            var nonExistingBookingId = BookingId.FromGuid(Guid.Parse("2a5be36a-618e-48d1-a0e7-a184f2081a72"));

            //Act & Assert
            Assert.Throws <InvalidOperationException>(() => account.DeleteBooking(nonExistingBookingId));
        }
Пример #27
0
        public void DeleteBooking_ExistingBookingId_BookingRemoved()
        {
            //Arrange
            var bookingIdGuid = Guid.Parse("b9c18f4d-8f11-408d-be7c-c7f022abefb2");
            var bookingId     = BookingId.FromGuid(bookingIdGuid);
            var payment       = Payment.FromDecimal(100.00m, "EUR");
            var bookingDate   = BookingDate.FromString("2020-09-26");
            var description   = Description.FromString("My payment");

            var accountIdGuid = Guid.Parse("9ccf4aa8-cd1e-4044-a183-464c8a8730ec");
            var account       = AccountRoot.Create(
                AccountId.FromGuid(accountIdGuid),
                UserId.FromGuid(Guid.Parse("13f172e2-7189-4506-b232-894bafcd4449")),
                Period.FromMonth(2020, 9),
                CurrencyCode.FromString("EUR"));

            account.BookPayment(bookingId, payment, bookingDate, description);

            //Act
            account.DeleteBooking(bookingId);

            //Assert
            Assert.AreEqual(0, account.Bookings.Count);
        }
Пример #28
0
        public async Task <bool> IsRecordAvailable(
            BookingId bookingId,
            FacilityId facilityId,
            EmployeeId employeeId,
            DateTime startDate,
            DateTime endDate)
        {
            var connection = sqlConnectionFactory.GetConnection();

            var result = await connection.QueryFirstOrDefaultAsync <int?>(
                @"SELECT 1
                FROM
                    booking.bookings b INNER JOIN
                    booking.booked_records r ON b.booking_id = r.booking_id
                WHERE
                    b.booking_id != @BookingId AND
                    b.status = @Status AND
                    b.facility_id = @FacilityId AND
                    r.status = @RecordStatus AND
                    r.employee_id = @EmployeeId AND
                    r.date < @EndDate AND
                    @StartDate < r.date + r.duration * INTERVAL '1 minute';",
                new
            {
                BookingId    = bookingId.Value,
                Status       = (int)BookingStatus.Booked,
                FacilityId   = facilityId.Value,
                RecordStatus = (int)BookedRecordStatus.Booked,
                EmployeeId   = employeeId.Value,
                StartDate    = startDate,
                EndDate      = endDate
            }
                );

            return(!result.HasValue);
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (entityId_ != null)
            {
                hash ^= EntityId.GetHashCode();
            }
            if (BookingId.Length != 0)
            {
                hash ^= BookingId.GetHashCode();
            }
            if (State != 0)
            {
                hash ^= State.GetHashCode();
            }
            if (guest_ != null)
            {
                hash ^= Guest.GetHashCode();
            }
            if (dateRange_ != null)
            {
                hash ^= DateRange.GetHashCode();
            }
            if (NumberAdults != 0)
            {
                hash ^= NumberAdults.GetHashCode();
            }
            if (NumberChildren != 0)
            {
                hash ^= NumberChildren.GetHashCode();
            }
            if (roomType_ != null)
            {
                hash ^= RoomType.GetHashCode();
            }
            hash ^= additionalGuests_.GetHashCode();
            if (TaxExempt != false)
            {
                hash ^= TaxExempt.GetHashCode();
            }
            if (cancellationPenaltyApplied_ != null)
            {
                hash ^= CancellationPenaltyApplied.GetHashCode();
            }
            if (CancellationReason.Length != 0)
            {
                hash ^= CancellationReason.GetHashCode();
            }
            if (cancellationPolicy_ != null)
            {
                hash ^= CancellationPolicy.GetHashCode();
            }
            if (RequestingParty.Length != 0)
            {
                hash ^= RequestingParty.GetHashCode();
            }
            if (cancellationDate_ != null)
            {
                hash ^= CancellationDate.GetHashCode();
            }
            if (CancellationNumber != 0L)
            {
                hash ^= CancellationNumber.GetHashCode();
            }
            hash ^= activeTags_.GetHashCode();
            return(hash);
        }
 public Booked(BookingId bookingId)
 {
     BookingId = bookingId;
 }
Пример #31
0
 public BookingRequested(FacilityId facilityId, BookingId bookingId)
 {
     FacilityId = facilityId;
     BookingId  = bookingId;
 }
 static StreamName GetStreamName(BookingId bookingId) => new($"hotel-booking-{bookingId}");