コード例 #1
0
        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);
        }
コード例 #2
0
 public void Remove(IWorkContext context)
 {
     this.ApplyEvent(new RemoveResourceEvent()
     {
         AggregateId = this.AggregateId,
         Creator     = context.GetWorkerName(),
         CreateDate  = context.WorkTime,
         Version     = this.Version
     });
 }
コード例 #3
0
 public void Remove(IWorkContext context, RemoveDepartmentCommand command)
 {
     //Never.StructTuple
     this.ApplyEvent(new RemoveDepartmentEvent
     {
         AggregateId = this.AggregateId,
         CreateDate  = context.WorkTime,
         Creator     = context.GetWorkerName(),
         Version     = this.Version,
     });
 }
コード例 #4
0
        public void Remove(IWorkContext context, RemoveGroupCommand command)
        {
            this.ApplyEvent(new RemoveGroupEvent()
            {
                AggregateId = this.AggregateId,
                CreateDate  = context.WorkTime,
                Creator     = context.GetWorkerName(),
                Version     = this.Version,

                DepartmentId = this.DepartmentId,
            });
        }
コード例 #5
0
        public void ChangeInfo(IWorkContext context, ChangeDepartmentInfoCommand command)
        {
            this.ApplyEvent(new ChangeDepartmentEvent
            {
                AggregateId = this.AggregateId,
                CreateDate  = context.WorkTime,
                Creator     = context.GetWorkerName(),
                Version     = this.Version,

                Name  = command.Name,
                Descn = command.Descn,
            });
        }
コード例 #6
0
        public void Remove(IWorkContext context)
        {
            this.ApplyEvent(new RemoveDepartmentResouceEvnet
            {
                AggregateId = this.AggregateId,
                CreateDate  = context.WorkTime,
                Creator     = context.GetWorkerName(),
                Version     = this.Version,

                DepartmentId = this.DepartmentId,
                ResourceId   = this.ResourceId,
            });
        }
コード例 #7
0
        public void Remove(IWorkContext context)
        {
            this.ApplyEvent(new RemoveEmployeeGroupEvent()
            {
                CreateDate  = context.WorkTime,
                Creator     = context.GetWorkerName(),
                Version     = this.Version,
                AggregateId = this.AggregateId,

                EmployeeId = this.EmployeeId,
                GroupId    = this.GroupId,
            });
        }
コード例 #8
0
        public EmployeeGroupAggregateRoot Create(IWorkContext context, CreateEmployeeGroupCommand commmand)
        {
            this.ApplyEvent(new CreateEmployeeGroupEvent()
            {
                Creator     = context.GetWorkerName(),
                AggregateId = this.AggregateId,
                Version     = this.Version,
                CreateDate  = context.WorkTime,
                EmployeeId  = commmand.EmployeeId,
                GroupId     = commmand.GroupId,
            });

            return(this);
        }
コード例 #9
0
        public void Remove(IWorkContext context, RemoveEmployeeCommand command)
        {
            this.ApplyEvent(new RemoveEmployeeEvent()
            {
                AggregateId = this.AggregateId,

                CreateDate   = context.WorkTime,
                Creator      = context.GetWorkerName(),
                Version      = this.Version,
                UserName     = this.UserName,
                DepartmentId = this.DepartmentId,
                GroupSort    = this.GroupSort,
            });
        }
コード例 #10
0
        public DepartmentAggregateRoot Create(IWorkContext context, CreateDepartmentCommand command)
        {
            this.ApplyEvent(new CreateDepartmentEvnet
            {
                AggregateId = this.AggregateId,
                CreateDate  = context.WorkTime,
                Creator     = context.GetWorkerName(),
                Version     = this.Version,

                Name  = command.Name,
                Descn = command.Descn,
            });

            return(this);
        }
コード例 #11
0
        public ResourceAggregateRoot Create(IWorkContext context, CreateResourceCommand command)
        {
            this.ApplyEvent(new CreateResourceEvent()
            {
                AggregateId = this.AggregateId,
                Version     = this.Version,
                CreateDate  = context.WorkTime,
                Creator     = context.GetWorkerName(),

                ActionDescn = command.Resource.ActionDescn,
                GroupSort   = command.Resource.GroupSort
            });

            return(this);
        }
コード例 #12
0
        public DepartmentResourceAggregateRoot Create(IWorkContext context, CreateDepartmentResourceCommand command)
        {
            this.ApplyEvent(new CreateDepartmentResouceEvnet
            {
                AggregateId = this.AggregateId,
                CreateDate  = context.WorkTime,
                Creator     = context.GetWorkerName(),
                Version     = this.Version,

                DepartmentId = command.DepartmentId,
                ResourceId   = command.ResourceId,
            });

            return(this);
        }
コード例 #13
0
 protected void Create(IWorkContext context, CreateEmployeeCommand command)
 {
     this.ApplyEvent(new CreateEmployeeEvent()
     {
         AggregateId  = this.AggregateId,
         UserName     = command.UserName,
         NickName     = command.NickName,
         Version      = this.Version,
         CreateDate   = context.WorkTime,
         Password     = command.Password,
         Creator      = context.GetWorkerName(),
         DepartmentId = command.DepartmentId,
         GroupSort    = command.GroupSort
     });
 }
コード例 #14
0
        public void ChangePassword(IWorkContext context, ChangeEmployeePasswordCommand command)
        {
            if (this.Password.IsEquals(command.Password))
            {
                return;
            }

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

                Password = command.Password,
            });
        }
コード例 #15
0
        public void ChangeInfo(IWorkContext context, string descn, GroupSort groupSort)
        {
            if (this.ActionDescn.IsEquals(descn) && this.GroupSort == groupSort)
            {
                return;
            }

            this.ApplyEvent(new ChangeResourceActionDescnEvent()
            {
                AggregateId = this.AggregateId,
                Creator     = context.GetWorkerName(),
                CreateDate  = context.WorkTime,
                Version     = this.Version,
                Descn       = descn,
                GroupSort   = groupSort
            });
        }
コード例 #16
0
        public void ChangeNickName(IWorkContext context, ChangeEmployeeNickNameCommand command)
        {
            if (this.NickName.IsEquals(command.NickName))
            {
                return;
            }

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

                NickName = command.NickName,
            });
        }
コード例 #17
0
        public void ChangeOwner(IWorkContext context, ChangeEmployeeOwnerCommand command)
        {
            //if (command.GroupSort >= current.GroupSort)
            //    throw new DomainException("你当前权限不能分配更高级的权限给别人");

            if (command.GroupSort >= GroupSort.Super)
            {
                throw new DomainException("你当前权限不能分配更高级的权限给别人");
            }

            this.ApplyEvent(new ChangeEmployeeOwnerEvent()
            {
                AggregateId  = this.AggregateId,
                Creator      = context.GetWorkerName(),
                CreateDate   = context.WorkTime,
                Version      = this.Version,
                DepartmentId = command.DepartmentId,
                GroupSort    = command.GroupSort,
            });
        }
コード例 #18
0
        public ValidationFailure?Destroy(IWorkContext context, DestroyEmailCodeCommand command)
        {
            if (this.UsageStatus == UsageStatus.已使用)
            {
                return(this.RejectBreak(this, m => m.ExpireTime, "验证码已使用"));
            }

            if (this.ExpireTime < context.WorkTime)
            {
                return(this.RejectBreak(this, m => m.ExpireTime, "验证码已过期"));
            }

            if (this.UsageType != command.UsageType)
            {
                return(this.RejectBreak(this, m => m.UsageType, "验证码不正确"));
            }

            if (this.UsageCode.IsNotEquals(command.VCode))
            {
                return(this.RejectBreak(this, m => m.UsageCode, "验证码错误"));
            }

            this.ApplyEvent(new DestroyEmailCodeEvent()
            {
                AggregateId = this.AggregateId,
                Version     = this.Version,
                CreateDate  = context.WorkTime,
                Creator     = context.GetWorkerName(),
                Email       = this.Email,
                UsageStatus = UsageStatus.已使用,
                UsageType   = this.UsageType,
                Message     = this.UsageCode,
            });

            return(null);
        }