예제 #1
0
        public override Task <bool> Process(string message)
        {
            // Deserialize the message into an object
            var request = JsonSerializer.Deserialize <Reservation>(message);

            Logger.LogInformation($"Got a reservation for {request.For}");
            // Log it out.
            // Business logic!
            var shouldApprove = request.Books.Split(',').Length;

            if (shouldApprove <= 3)
            {
                // If Approved - POST /reservations/approved
                return(Service.MarkReservationApproved(request));
            }
            else
            {
                // If Denied - POST /reservations/denied
                return(Service.MarkReservationDenied(request));
            }
        }
        public override async Task <bool> Process(string message)
        {
            // 1. message body is a string, deserialize it into a .NET object
            var request = JsonSerializer.Deserialize <ReservationMessage>(message);

            // 2. maybe log it so we can see it
            Logger.LogInformation($"Got a reservation for {request.For}");

            // 3. do the business stuff, processes the reservation
            var isOk = request.Books.Split(',').Count() % 2 == 0;

            // 4. Tell the API about it
            if (isOk)
            {
                return(await Service.MarkReservationApproved(request));
            }
            else
            {
                return(await Service.MarkReservationDenied(request));
            }
        }