Esempio n. 1
0
        public async Task <Book> TrySetAvailableAsync(string id)
        {
            var book = await BookStorage.ReadByIdAsync(id);

            if (book.IsAvailable)
            {
                throw new InvalidOperationException("that book is already available.");
            }

            book.IsAvailable = true;
            await BookStorage.UpdateAsync(book);

            return(book);
        }
Esempio n. 2
0
 public async Task <Book> GetBookByIdAsync(string id)
 {
     return(await BookStorage.ReadByIdAsync(id));
 }