Пример #1
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,
            });
        }
        public ICommandHandlerResult Execute(ICommandContext context, RemoveEmployeeCommand command)
        {
            var root = context.GetAggregateRoot(command.AggregateId, () => employeeRepository.Rebuild(command.AggregateId));

            if (root == null)
            {
                return(context.CreateResult(CommandHandlerStatus.NotExists));
            }

            root.Remove(context, command);
            if (root.CanNotCommit())
            {
                return(context.CreateResult(CommandHandlerStatus.NothingChanged));
            }

            if (employeeRepository.Remove(root) <= 0)
            {
                throw new RepositoryExcutingException("执行失败,请稍后再试");
            }

            return(context.CreateResult(CommandHandlerStatus.Success));
        }
Пример #3
0
 public Task <Unit> Handle(RemoveEmployeeCommand request, CancellationToken cancellationToken)
 {
     throw new NotImplementedException();
 }