private static Task <ConfirmParkingResponse> ConfirmParking(
            ConfirmParkingRequest request,
            LicensePlateRegistration licensePlateRegistration,
            DurableOrchestrationContextBase context)
        {
            Task <ConfirmParkingResponse> confirmTask;

            switch (licensePlateRegistration.Type)
            {
            case LicensePlateType.Appointment:
                confirmTask = context.CallActivityAsync <ConfirmParkingResponse>(
                    nameof(ConfirmParkingForAppointment),
                    request);
                break;

            case LicensePlateType.Employee:
                confirmTask = context.CallActivityAsync <ConfirmParkingResponse>(
                    nameof(ConfirmParkingForEmployee),
                    request);
                break;

            default:
                var unknownLicencePlateResponse = ConfirmParkingResponseBuilder.BuildWithFailedUnknownLicensePlate(request.ParkingGarageName);
                confirmTask = Task.FromResult(unknownLicencePlateResponse);
                break;
            }

            return(confirmTask);
        }
        public async Task <ConfirmParkingResponse> ConfirmParkingAsync(
            ConfirmParkingRequest request,
            bool hasReservation)
        {
            var parkingGarage = await _repository.GetByNameAsync(request.ParkingGarageName);

            var occupySpaceResult = parkingGarage.OccupyParkingSpace(hasReservation);

            return(ConfirmParkingResponseBuilder.Build(parkingGarage.Name, occupySpaceResult));
        }
Ejemplo n.º 3
0
        public static async Task <ConfirmParkingResponse> Run(
            [ActivityTrigger] ConfirmParkingRequest request,
            [Inject] IParkingConfirmationService parkingConfirmationService,
            ILogger logger)
        {
            logger.LogInformation($"Started {nameof(ConfirmParkingForEmployee)} for licensePlate {request.LicensePlateRegistration.Number}.");

            var response = await parkingConfirmationService.ConfirmParkingAsync(request, false);

            return(response);
        }