Ejemplo n.º 1
0
        protected override async Task TriggerTestAction(OpenBookingSimulateAction simulateAction, FacilityOpportunity idComponents)
        {
            switch (simulateAction)
            {
            case ChangeOfLogisticsTimeSimulateAction _:
                if (!await FakeBookingSystem.Database.UpdateFacilitySlotStartAndEndTimeByPeriodInMins(idComponents.SlotId.Value, 60))
                {
                    throw new OpenBookingException(new UnknownOpportunityError());
                }
                return;

            case ChangeOfLogisticsNameSimulateAction _:
                if (!await FakeBookingSystem.Database.UpdateFacilityUseName(idComponents.SlotId.Value, "Updated Facility Title"))
                {
                    throw new OpenBookingException(new UnknownOpportunityError());
                }
                return;

            case ChangeOfLogisticsLocationSimulateAction _:
                if (!await FakeBookingSystem.Database.UpdateFacilityUseLocationLatLng(idComponents.SlotId.Value, 0.2m, 0.3m))
                {
                    throw new OpenBookingException(new UnknownOpportunityError());
                }
                return;

            default:
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 2
0
        async Task IOpportunityStore.TriggerTestAction(OpenBookingSimulateAction simulateAction, IBookableIdComponents idComponents)
        {
            if (!(idComponents.GetType() == typeof(TComponents)))
            {
                throw new NotSupportedException($"OpportunityIdComponents does not match {typeof(BookablePairIdTemplate<TComponents>).ToString()}. All types of IBookableIdComponents (T) used for BookablePairIdTemplate<T> assigned to feeds via settings.IdConfiguration must match those used by the stores in storeSettings.OpenBookingStoreRouting.");
            }

            await TriggerTestAction(simulateAction, (TComponents)idComponents);
        }
Ejemplo n.º 3
0
        async Task <ResponseContent> IBookingEngine.TriggerTestAction(string actionJson)
        {
            OpenBookingSimulateAction action = OpenActiveSerializer.Deserialize <OpenBookingSimulateAction>(actionJson);

            if (action == null)
            {
                throw new OpenBookingException(new OpenBookingError(), "Invalid type specified. Type must subclass OpenBookingSimulateAction.");
            }

            if (!action.Object.HasValue || ((Schema.NET.JsonLdObject)action.Object.Value).Id == null)
            {
                throw new OpenBookingException(new OpenBookingError(), "Invalid OpenBookingSimulateAction object specified.");
            }

            await this.TriggerTestAction(action, settings.OrderIdTemplate);

            return(ResponseContent.OpenBookingNoContentResponse());
        }
Ejemplo n.º 4
0
 protected abstract Task TriggerTestAction(OpenBookingSimulateAction simulateAction, OrderIdTemplate orderIdTemplate);
Ejemplo n.º 5
0
        public override async Task TriggerTestAction(OpenBookingSimulateAction simulateAction, OrderIdComponents orderId)
        {
            switch (simulateAction)
            {
            case SellerAcceptOrderProposalSimulateAction _:
                if (orderId.OrderType != OrderType.OrderProposal)
                {
                    throw new OpenBookingException(new UnexpectedOrderTypeError(), "Expected OrderProposal");
                }
                if (!await FakeBookingSystem.Database.AcceptOrderProposal(orderId.uuid))
                {
                    throw new OpenBookingException(new UnknownOrderError());
                }
                break;

            case SellerAmendOrderProposalSimulateAction _:
                if (orderId.OrderType != OrderType.OrderProposal)
                {
                    throw new OpenBookingException(new UnexpectedOrderTypeError(), "Expected OrderProposal");
                }
                var version = Guid.NewGuid();
                if (!await FakeBookingSystem.Database.AmendOrderProposal(orderId.uuid, version))
                {
                    throw new OpenBookingException(new UnknownOrderError());
                }
                break;

            case SellerRejectOrderProposalSimulateAction _:
                if (orderId.OrderType != OrderType.OrderProposal)
                {
                    throw new OpenBookingException(new UnexpectedOrderTypeError(), "Expected OrderProposal");
                }
                if (!await FakeBookingSystem.Database.RejectOrderProposal(null, null, orderId.uuid, false))
                {
                    throw new OpenBookingException(new UnknownOrderError());
                }
                break;

            case SellerRequestedCancellationWithMessageSimulateAction _:
                if (orderId.OrderType != OrderType.Order)
                {
                    throw new OpenBookingException(new UnexpectedOrderTypeError(), "Expected Order");
                }
                if (!await FakeBookingSystem.Database.CancelOrderItems(null, null, orderId.uuid, null, false, true))
                {
                    throw new OpenBookingException(new UnknownOrderError());
                }
                break;

            case SellerRequestedCancellationSimulateAction _:
                if (orderId.OrderType != OrderType.Order)
                {
                    throw new OpenBookingException(new UnexpectedOrderTypeError(), "Expected Order");
                }
                if (!await FakeBookingSystem.Database.CancelOrderItems(null, null, orderId.uuid, null, false))
                {
                    throw new OpenBookingException(new UnknownOrderError());
                }
                break;

            case AccessCodeUpdateSimulateAction _:
                if (orderId.OrderType != OrderType.Order)
                {
                    throw new OpenBookingException(new UnexpectedOrderTypeError(), "Expected Order");
                }
                if (!await FakeBookingSystem.Database.UpdateAccess(orderId.uuid, updateAccessCode: true))
                {
                    throw new OpenBookingException(new UnknownOrderError());
                }
                break;

            case AccessPassUpdateSimulateAction _:
                if (orderId.OrderType != OrderType.Order)
                {
                    throw new OpenBookingException(new UnexpectedOrderTypeError(), "Expected Order");
                }
                if (!await FakeBookingSystem.Database.UpdateAccess(orderId.uuid, updateAccessPass: true))
                {
                    throw new OpenBookingException(new UnknownOrderError());
                }
                break;

            case AttendeeAttendedSimulateAction _:
                if (orderId.OrderType != OrderType.Order)
                {
                    throw new OpenBookingException(new UnexpectedOrderTypeError(), "Expected Order");
                }
                if (!await FakeBookingSystem.Database.UpdateOpportunityAttendance(orderId.uuid, true))
                {
                    throw new OpenBookingException(new UnknownOrderError());
                }
                break;

            case AttendeeAbsentSimulateAction _:
                if (orderId.OrderType != OrderType.Order)
                {
                    throw new OpenBookingException(new UnexpectedOrderTypeError(), "Expected Order");
                }
                if (!await FakeBookingSystem.Database.UpdateOpportunityAttendance(orderId.uuid, false))
                {
                    throw new OpenBookingException(new UnknownOrderError());
                }
                break;

            case CustomerNoticeSimulateAction _:
                if (orderId.OrderType != OrderType.Order)
                {
                    throw new OpenBookingException(new UnexpectedOrderTypeError(), "Expected Order");
                }
                if (!await FakeBookingSystem.Database.AddCustomerNotice(orderId.uuid))
                {
                    throw new OpenBookingException(new UnknownOrderError());
                }
                break;

            case ReplacementSimulateAction _:
                if (orderId.OrderType != OrderType.Order)
                {
                    throw new OpenBookingException(new UnexpectedOrderTypeError(), "Expected Order");
                }
                if (!await FakeBookingSystem.Database.ReplaceOrderOpportunity(orderId.uuid))
                {
                    throw new OpenBookingException(new UnknownOrderError());
                }
                break;

            case AccessChannelUpdateSimulateAction _:
                if (orderId.OrderType != OrderType.Order)
                {
                    throw new OpenBookingException(new UnexpectedOrderTypeError(), "Expected Order");
                }
                if (!await FakeBookingSystem.Database.UpdateAccess(orderId.uuid, updateAccessChannel: true))
                {
                    throw new OpenBookingException(new UnknownOrderError());
                }
                break;
            }
        }
Ejemplo n.º 6
0
 protected abstract Task TriggerTestAction(OpenBookingSimulateAction simulateAction, TComponents idComponents);