public async Task <ApiResult> AddAsync(SubmitDTO <XsTaskBaseDTO> model) { var dto = model.Data; //转换为数据库实体 XsTaskBaseDO XsTaskBaseDO = this.ObjectMapper.Map <XsTaskBaseDO>(dto); XsTaskBaseDO.CreateBy = model.UserId; XsTaskBaseDO.CreateByName = model.UserName; XsTaskBaseDO.CreateDate = System.DateTime.Now; XsTaskBaseDO.ModityBy = model.UserId; XsTaskBaseDO.ModityByName = model.UserName; XsTaskBaseDO.ModityDate = System.DateTime.Now; bool bRet = await _xstaskbaseRepository.AddAsync(XsTaskBaseDO); if (!bRet) { return(ApiResultUtil.IsFailed("数据插入失败!")); } //string sql = _XsTaskBaseRepository.ExecuteScript; //更新服务状态 XsTaskBaseState XsTaskBaseState = this.ObjectMapper.Map <XsTaskBaseState>(XsTaskBaseDO); await this.Persist(ProcessAction.Create, XsTaskBaseState); return(ApiResultUtil.IsSuccess(dto.Id.ToString())); }
public async Task <ApiResult> UpdateAsync(SubmitDTO <XsTaskBaseDTO> model) { var dto = model.Data; if (dto.Version != this.State.Version) { return(ApiResultUtil.IsFailed("数据已被修改,请重新再加载!")); } dto.Version++; XsTaskBaseState XsTaskBaseState = this.State; if (dto.IsDel != 1) { //赋值 } XsTaskBaseState.IsDel = dto.IsDel; XsTaskBaseState.ModityBy = model.UserId; XsTaskBaseState.ModityByName = model.UserName; XsTaskBaseState.ModityDate = System.DateTime.Now; XsTaskBaseState.Version = dto.Version; XsTaskBaseDO XsTaskBaseDO = this.ObjectMapper.Map <XsTaskBaseDO>(XsTaskBaseState); bool bRet = await _xstaskbaseRepository.SetAsync(XsTaskBaseDO); if (!bRet) { return(ApiResultUtil.IsFailed("数据更新失败!")); } await this.Persist(ProcessAction.Update, XsTaskBaseState); return(ApiResultUtil.IsSuccess()); }