public ReleaseState Update(params ReleaseUpdateCommand[] commands) { var state = new ReleaseState(this); var stream = commands.OrderBy(m => m.Timestamp); foreach (var cmd in stream) { if (cmd.Timestamp <= state.Timestamp) { continue; } if (!string.IsNullOrEmpty(cmd.Title)) { state.Title = cmd.Title; } if (!string.IsNullOrEmpty(cmd.Artist)) { state.Artist = cmd.Artist; } if (!string.IsNullOrEmpty(cmd.Genre)) { state.Genre = cmd.Genre; } if (cmd.Cover != null) { state.Cover = cmd.Cover; } state.Timestamp = cmd.Timestamp; } return(state); }
public ReleaseState ReplaceSubscription(SubscriptionReplaceCommand command) { var state = new ReleaseState(this); state.Subscription = new SubscriptionState(command); return(state); }
public ReleaseState AddSubscription(string subscriptionId, SubscriptionCreateCommand command) { var state = new ReleaseState(this); state.Subscription = new SubscriptionState(subscriptionId, command); return(state); }
public ReleaseState(ReleaseState copyFrom) { this.ReleaseId = copyFrom.ReleaseId; this.Artist = copyFrom.Artist; this.Cover = copyFrom.Cover; this.Genre = copyFrom.Genre; this.Title = copyFrom.Title; this.Timestamp = copyFrom.Timestamp; this.TrackList = copyFrom.TrackList; }
public ReleaseState UpdateMetadata(MetadataUpdateCommand command) { if (!this.TrackList.ContainsKey(command.TrackId) || command.Timestamp <= this.Timestamp) { return(this); } var state = new ReleaseState(this); state.Timestamp = command.Timestamp; var metadata = TrackList[command.TrackId]; state.TrackList = state.TrackList.SetItem(command.TrackId, metadata.Update(command)); return(state); }
public ReleaseState AddMetadata(MetadataCreateCommand command) { if (this.TrackList.ContainsKey(command.TrackId) || command.Timestamp <= this.Timestamp) { return(this); } var state = new ReleaseState(this); state.TrackList = this.TrackList.Add(command.TrackId, new MetadataState(command.TrackId, command.ReleaseId, command.Title, command.Artist, command.Album, command.Genre, command.Number)); state.Timestamp = command.Timestamp; return(state); }