Exemplo n.º 1
0
        public static async Task <StatusHandler> ProcessBookAsync_NoValidation(this IProcessable processable, LibraryBook libraryBook)
        {
            Serilog.Log.Logger.Information("Begin " + nameof(ProcessBookAsync_NoValidation) + " {@DebugInfo}", new
            {
                libraryBook.Book.Title,
                libraryBook.Book.AudibleProductId,
                libraryBook.Book.Locale,
                Account = libraryBook.Account?.ToMask() ?? "[empty]"
            });

            var status
                = (await processable.ProcessAsync(libraryBook))
                  ?? new StatusHandler {
                "Processable should never return a null status"
                };

            return(status);
        }
Exemplo n.º 2
0
        private static async Task <StatusHandler> processBookAsync(IProcessable processable, LibraryBook libraryBook)
        {
            Serilog.Log.Logger.Information("Begin " + nameof(processBookAsync) + " {@DebugInfo}", new
            {
                libraryBook.Book.Title,
                libraryBook.Book.AudibleProductId,
                libraryBook.Book.Locale,
                libraryBook.Account
            });

            // this should never happen. check anyway. ProcessFirstValidAsync returning null is the signal that we're done. we can't let another IProcessable accidentally send this command
            var status = await processable.ProcessAsync(libraryBook);

            if (status == null)
            {
                throw new Exception("Processable should never return a null status");
            }

            return(status);
        }
Exemplo n.º 3
0
 public static async Task <StatusHandler> TryProcessAsync(this IProcessable processable, LibraryBook libraryBook)
 => processable.Validate(libraryBook)
                 ? await processable.ProcessAsync(libraryBook)
                 : new StatusHandler();