public ICommandHandlerResult Execute(ICommandContext context, CreateDepartmentCommand command)
        {
            var root = context.GetAggregateRoot(command.AggregateId, () => DepartmentAggregateRoot.Register(context, command));

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

            var rowId = departmentRepository.Save(root);

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

            return(context.CreateResult(CommandHandlerStatus.Success));
        }
 /// <summary>
 /// 更新部门
 /// </summary>
 /// <param name="root"></param>
 /// <returns></returns>
 public int Change(DepartmentAggregateRoot root)
 {
     return(this.daoBuilder.Build().ToEasyXmlDao(root).Update("updateDepartmentRoot"));
 }
 /// <summary>
 /// 删除部门
 /// </summary>
 /// <param name="root"></param>
 /// <returns></returns>
 public int Remove(DepartmentAggregateRoot root)
 {
     return(this.daoBuilder.Build().ToEasyXmlDao(root).Delete("deleteDepartmentRoot"));
 }
 /// <summary>
 /// 插入部门
 /// </summary>
 /// <param name="root"></param>
 /// <returns></returns>
 public int Save(DepartmentAggregateRoot root)
 {
     return(this.daoBuilder.Build().ToEasyXmlDao(root).Insert <int>("insertDepartmentRoot"));
 }