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)); }
/// <summary> /// 删除员工 /// </summary> /// <param name="root"></param> /// <returns></returns> public int Remove(EmployeeAggregateRoot root) { return(this.daoBuilder.Build().ToEasyXmlDao(root).Delete("deleteEmployeeRoot")); }
/// <summary> /// 更新员工 /// </summary> /// <param name="root"></param> /// <returns></returns> public int Change(EmployeeAggregateRoot root) { return(this.daoBuilder.Build().ToEasyXmlDao(root).Update("updateEmployeeRoot")); }
/// <summary> /// 插入员工 /// </summary> /// <param name="root"></param> /// <returns></returns> public int Save(EmployeeAggregateRoot root) { return(this.daoBuilder.Build().ToEasyXmlDao(root).Insert <int>("insertEmployeeRoot")); }