public ICommandHandlerResult Execute(ICommandContext context, CreateGroupCommand command) { var department = this.departmentRepository.Rebuild(command.DepartmentId); if (department == null) { return(context.CreateResult(CommandHandlerStatus.NotExists)); } var root = context.GetAggregateRoot(command.AggregateId, () => GroupAggregateRoot.Register(context, command, department)); if (root.CanNotCommit()) { return(context.CreateResult(CommandHandlerStatus.Fail)); } if (groupRepository.Save(root) <= 0) { throw new RepositoryExcutingException("执行失败,请稍后再试"); } return(context.CreateResult(CommandHandlerStatus.Success)); }
/// <summary> /// 删除小组 /// </summary> /// <param name="root"></param> /// <returns></returns> public int Remove(GroupAggregateRoot root) { return(this.daoBuilder.Build().ToEasyXmlDao(root).Delete("deleteGroupRoot")); }
/// <summary> /// 更新小组 /// </summary> /// <param name="root"></param> /// <returns></returns> public int Change(GroupAggregateRoot root) { return(this.daoBuilder.Build().ToEasyXmlDao(root).Update("updateGroupRoot")); }
/// <summary> /// 创建小组 /// </summary> /// <param name="root"></param> /// <returns></returns> public int Save(GroupAggregateRoot root) { return(this.daoBuilder.Build().ToEasyXmlDao(root).Insert <int>("insertGroupRoot")); }