public async Task <Result> Handle(RemovePlaylistCommand command, CancellationToken cancellationToken)
    {
        var playlist = await _context.Playlists.Include(x => x.Subreddits).FirstOrDefaultAsync(playlist => playlist.Id == command.PlaylistId);

        if (playlist == null)
        {
            return((await Result.FailAsync("Playlist not found")) as Result);
        }

        _context.Playlists.Remove(playlist);
        await _context.SaveChangesAsync(cancellationToken);

        return((await Result.SuccessAsync("Playlist removed")) as Result);
    }
Beispiel #2
0
 public async Task <IActionResult> Remove(RemovePlaylistCommand command)
 {
     return(Ok(await Mediator.Send(command)));
 }