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"));
 }
Exemple #2
0
 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);
 }
Exemple #3
0
 private bool HandleUpdateMessage(ReleaseUpdateCommand cmd)
 {
     if (IsMessageValid(cmd))
     {
         Persist(cmd, c =>
         {
             UpdateState(c);
             TellStateUpdated();
         });
         return(true);
     }
     return(false);
 }
Exemple #4
0
 private void UpdateState(ReleaseUpdateCommand command)
 {
     _state = _state.Update(command);
 }
Exemple #5
0
 public void UpdateRelease(ReleaseUpdateCommand updateRelease)
 {
     WithValidation(() => CommandValidator.Validate(updateRelease));
     ActorModel.TellReleaseActor(updateRelease.ReleaseId, updateRelease);
 }
 public void UpdateRelease([FromBody] ReleaseUpdateCommand command)
 {
     _releaseService.UpdateRelease(command);
 }