public Either <DomainError, CommandResult> Handle(ArchivePlayList command) { var playList = playListPersistence.GetPlayList(command.PlaylistId); playList.Archive(); playListPersistence.Persist(playList); eventPublisher.Publish(playList.Events()); return(CommandResult.Success); }
public void archive_a_play_list() { var aPlaylistId = APlaylist.Id; var aPlayList = new PlayListBuilder() .WithId(aPlaylistId) .WithStatus(PlayListStatus.Active) .Build(); playListPersistence.GetPlayList(aPlaylistId).Returns(aPlayList); var command = new ArchivePlayList(aPlaylistId); var result = archivePlayListCommandHandler.Handle(command); result.IsRight.Should().BeTrue(); VerifyPlayListHasBeenPersistedWith(aPlaylistId, PlayListStatus.Archived); VerifyEventHasBeenRaised(new PlayListHasBeenArchived(aPlaylistId), eventPublisher); }
public Either <DomainError, CommandResult> Process(ArchivePlayList command) { var commandHandler = playListCommandHandlerCreator.CreateArchivePlayListCommandHandler(); return(commandHandler.Handle(command)); }