public EmailCodeAggregateRoot Create(IWorkContext context, CreateEmailCodeCommand command) { var length = command.Length; if (length <= 0) { length = 4; } else if (length > 10) { length = 10; } this.ApplyEvent(new CreateEmailCodeEvent() { AggregateId = this.AggregateId, Version = this.Version, CreateDate = context.WorkTime, Creator = context.GetWorkerName(), Email = command.Email, UsageType = command.UsageType, Message = string.Join("", Randomizer.PokerArray(10, length)), ClientIP = command.ClientIP, Platform = command.Platform, ExpireTime = this.CreateDate.AddMinutes(5), }); return(this); }
public static EmailCodeAggregateRoot Register(IWorkContext context, CreateEmailCodeCommand command) { return(new EmailCodeAggregateRoot(command.AggregateId).Create(context, command)); }