コード例 #1
0
        public async Task <IActionResult> DeleteGenreById([FromRoute] int id)
        {
            if (!await IsUserAdmin())
            {
                return(Forbid());
            }

            var genre = await _genreManager.GetGenreWithVideos(id);

            if (genre == null)
            {
                return(BadRequest("Genre not found"));
            }

            _genreManager.RemoveGenre(genre);
            await _genreManager.SaveChangesAsync();

            return(Ok());
        }