Ejemplo n.º 1
0
        public async Task <IViewComponentResult> InvokeAsync(IModelRepository _repository)
        {
            try
            {
                var books = await _repository.Books();

                var user = await _manager.GetUserAsync((ClaimsPrincipal)User);

                var current          = books.FirstOrDefault(b => b.IsCurrent);
                CheckoutViewModel vm = new CheckoutViewModel
                {
                    Book   = current,
                    Member = user
                };
                return(View(vm));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Failed to retrieve books: {ex.Message}");
                return(View(new Book()));
            }
        }