public ReleaseState ReplaceSubscription(SubscriptionReplaceCommand command) { var state = new ReleaseState(this); state.Subscription = new SubscriptionState(command); return(state); }
public static ValidationResult Validate(SubscriptionReplaceCommand command) { if (command != null && !string.IsNullOrEmpty(command.ReleaseId) && command.UtcExpiration > DateTime.UtcNow) { return(ValidationResult.Ok); } return(ValidationResult.ErrorOf("Command has to have release id specified and have expiration date greater than UTC Now")); }
public SubscriptionState(SubscriptionReplaceCommand command) { SubscriptionId = command.SubscriptionId; UtcExpiration = command.UtcExpiration; ReleaseId = command.ReleaseId; ShopIds = command.ShopIds; Cost = command.Cost; Timestamp = command.Timestamp; }
private bool OnSubscriptionReplace(SubscriptionReplaceCommand command) { if (!IsSubscriptionValid(command)) { return(false); } PersistAsync(command, cmd => { _state = _state.ReplaceSubscription(command); TellStateUpdated(); }); return(true); }
private bool IsSubscriptionValid(SubscriptionReplaceCommand command) { return(command != null && command.ReleaseId == PersistenceId && command.UtcExpiration > DateTime.UtcNow && _state.Subscription != null && _state.Subscription.SubscriptionId == command.SubscriptionId); }