public ICommandResult Handle(CreateSongCommand command) { var singerQuery = _singerRepository.GetById(command.SingerId); var albumQuery = _albumRepository.GetById(command.AlbumId); Name singerName = new Name(singerQuery.FirstName, singerQuery.LastName); Singer singer = new Singer(singerQuery.Id, singerName, singerQuery.Nationality, singerQuery.About, singerQuery.Image); Album album = new Album(albumQuery.Id, albumQuery.Title, null, null, albumQuery.Image); Song song = new Song(command.Title, singer, album, command.Url, command.PublishedDate); AddNotifications(song.Notifications); if (Invalid) { return(new CommandResult(false, MessagesUtil.FormFail, Notifications)); } bool result = _repository.Create(song); if (!result) { return(new CommandResult(false, MessagesUtil.CreateError, Notifications)); } return(new CommandResult(true, MessagesUtil.CreatedSuccess)); }
public GetSingerByIdQuery GetById(Guid id) { return(_repository.GetById(id)); }