Beispiel #1
0
        public async Task Return([FromRoute] int bookId)
        {
            var currentUserName = User.FindFirst(ClaimTypes.Name).Value;

            if (currentUserName == null)
            {
                throw new InvalidOperationException("User does not have a Name/ID");
            }

            var user = await _bookShelfService.FindUserAsync(currentUserName);

            try
            {
                await _bookShelfService.ReturnBookAsync(user, bookId);
            }
            catch (InvalidOperationException e)
            {
                BadRequest(e.Message);
            }
        }