public static ValidationResult Validate(ReleaseUpdateCommand cmd) { if (!string.IsNullOrEmpty(cmd.Title) || !string.IsNullOrEmpty(cmd.Genre) || !string.IsNullOrEmpty(cmd.Artist) || cmd.Cover != null) { return(ValidationResult.Ok); } return(ValidationResult.ErrorOf("Command has to update at least one field")); }
private bool IsMessageValid(ReleaseUpdateCommand cmd) { if (cmd == null || cmd.ReleaseId != PersistenceId) { return(false); } if (_state.Timestamp >= cmd.Timestamp) { return(false); } return(CommandValidator.Validate(cmd).Success); }
private bool HandleUpdateMessage(ReleaseUpdateCommand cmd) { if (IsMessageValid(cmd)) { Persist(cmd, c => { UpdateState(c); TellStateUpdated(); }); return(true); } return(false); }
private void UpdateState(ReleaseUpdateCommand command) { _state = _state.Update(command); }
public void UpdateRelease(ReleaseUpdateCommand updateRelease) { WithValidation(() => CommandValidator.Validate(updateRelease)); ActorModel.TellReleaseActor(updateRelease.ReleaseId, updateRelease); }
public void UpdateRelease([FromBody] ReleaseUpdateCommand command) { _releaseService.UpdateRelease(command); }