Exemple #1
0
        public async Task <IActionResult> Create(Book book)
        {
            if (ModelState.IsValid)
            {
                bool isAdmin = await _cs.IsItAdminAsync(User.Identity.Name);

                if (!isAdmin)
                {
                    return(Unauthorized());
                }
                await _bc.CreateAsync(book);

                await _bc.CommitAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }