示例#1
0
        public async Task <IActionResult> Post(BookDto book)
        {
            if (!await _subscriptionsService.DoesBookExists(book.BookId))
            {
                return(BadRequest("Book subscription doesn't exist"));
            }

            if (await _subscriptionsService.IsSubscriptionAlreadyPurchased(book.BookId))
            {
                return(BadRequest("Book subscription is already purchased"));
            }

            var result = await _subscriptionsService.PurchaseSubscription(book);

            return(Ok(result));
        }