コード例 #1
0
        public IActionResult CheckoutALibraryBook(Guid bookId)
        {
            ILibraryBook book = _libraryService.Book(bookId);

            string message = string.Empty;

            if (book != null)
            {
                DateTime dueDate = DateTime.Now.AddDays(30);

                CheckoutResult result = book.Checkout();

                if (result.CheckedOutResultStatus == CheckedOutResultStatus.Ok)
                {
                    return(Ok(new { BookId = bookId, DueDate = dueDate }));
                }
                message = result.Message;
            }

            return(BadRequest(message));
        }