Example #1
0
        protected MobileCodeAggregateRoot Create(IWorkContext context, CreateMobileCodeCommand command)
        {
            var length = command.Length;

            if (length <= 0)
            {
                length = 4;
            }
            else if (length > 10)
            {
                length = 10;
            }

            this.ApplyEvent(new CreateMobileCodeEvent()
            {
                AggregateId = this.AggregateId,
                Version     = this.Version,
                CreateDate  = context.WorkTime,
                Creator     = context.GetWorkerName(),

                Mobile     = command.Mobile.AsLong(),
                UsageType  = command.UsageType,
                Message    = string.Join("", Randomizer.PokerArray(10, length)),
                ClientIP   = command.ClientIP,
                Platform   = command.Platform,
                ExpireTime = this.CreateDate.AddMinutes(5),
            });

            return(this);
        }
Example #2
0
 public static MobileCodeAggregateRoot Register(IWorkContext context, CreateMobileCodeCommand command)
 {
     return(new MobileCodeAggregateRoot(command.AggregateId).Create(context, command));
 }