예제 #1
0
        public ReleaseState ReplaceSubscription(SubscriptionReplaceCommand command)
        {
            var state = new ReleaseState(this);

            state.Subscription = new SubscriptionState(command);
            return(state);
        }
예제 #2
0
 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"));
 }
예제 #3
0
 public SubscriptionState(SubscriptionReplaceCommand command)
 {
     SubscriptionId = command.SubscriptionId;
     UtcExpiration  = command.UtcExpiration;
     ReleaseId      = command.ReleaseId;
     ShopIds        = command.ShopIds;
     Cost           = command.Cost;
     Timestamp      = command.Timestamp;
 }
예제 #4
0
        private bool OnSubscriptionReplace(SubscriptionReplaceCommand command)
        {
            if (!IsSubscriptionValid(command))
            {
                return(false);
            }

            PersistAsync(command, cmd =>
            {
                _state = _state.ReplaceSubscription(command);
                TellStateUpdated();
            });
            return(true);
        }
예제 #5
0
 private bool IsSubscriptionValid(SubscriptionReplaceCommand command)
 {
     return(command != null && command.ReleaseId == PersistenceId && command.UtcExpiration > DateTime.UtcNow &&
            _state.Subscription != null && _state.Subscription.SubscriptionId == command.SubscriptionId);
 }