/// <summary> /// 新增AbpDataDict /// </summary> protected virtual async Task <AbpDataDictEditDto> Create(AbpDataDictEditDto input) { //TODO:新增前的逻辑判断,是否允许新增 // var entity = ObjectMapper.Map <AbpDataDict>(input); var entity = input.MapTo <AbpDataDict>(); entity.TenantId = this.AbpSession.TenantId; entity = await _entityRepository.InsertAsync(entity); return(entity.MapTo <AbpDataDictEditDto>()); }
/// <summary> /// 编辑AbpDataDict /// </summary> protected virtual async Task Update(AbpDataDictEditDto input) { var data_count = await _entityRepository.CountAsync(x => x.Id == input.Id); //TODO:更新前的逻辑判断,是否允许更新 if (data_count == 1) { var entity = await _entityRepository.GetAsync(input.Id.Value); input.MapTo(entity); // ObjectMapper.Map(input, entity); await _entityRepository.UpdateAsync(entity); } else { throw new UserFriendlyException("该字典不能被用户修改"); } }