コード例 #1
0
        public ICommandHandlerResult Execute(ICommandContext context, CreateEmployeeCommand command)
        {
            var root = context.GetAggregateRoot(command.AggregateId, () => EmployeeAggregateRoot.Register(context, command));

            if (root.CanNotCommit())
            {
                return(context.CreateResult(CommandHandlerStatus.Fail));
            }

            var rowId = employeeRepository.Save(root);

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

            return(context.CreateResult(CommandHandlerStatus.Success));
        }
コード例 #2
0
 /// <summary>
 /// 删除员工
 /// </summary>
 /// <param name="root"></param>
 /// <returns></returns>
 public int Remove(EmployeeAggregateRoot root)
 {
     return(this.daoBuilder.Build().ToEasyXmlDao(root).Delete("deleteEmployeeRoot"));
 }
コード例 #3
0
 /// <summary>
 /// 更新员工
 /// </summary>
 /// <param name="root"></param>
 /// <returns></returns>
 public int Change(EmployeeAggregateRoot root)
 {
     return(this.daoBuilder.Build().ToEasyXmlDao(root).Update("updateEmployeeRoot"));
 }
コード例 #4
0
 /// <summary>
 /// 插入员工
 /// </summary>
 /// <param name="root"></param>
 /// <returns></returns>
 public int Save(EmployeeAggregateRoot root)
 {
     return(this.daoBuilder.Build().ToEasyXmlDao(root).Insert <int>("insertEmployeeRoot"));
 }