public virtual async Task <FaultGradeDto> CreateFaultGradeAsync(CreateFaultGradeInput input) { var result = await _faultGradeRemoteAppService.CreateAsync(input); return(result); //return null; }
/// <summary> /// 创建报警级别 /// </summary> /// <param name="input"></param> /// <returns></returns> /// <remarks>Create by 2</remarks> //[Authorize(TestServicePermissions.FaultGrade.Create)] public virtual async Task <FaultGradeDto> CreateAsync(CreateFaultGradeInput input) { var ccc = _currentUser.Name; var languages = await _languageProvider.GetLanguagesAsync(); var currentLanguage = languages.FindByCulture( CultureInfo.CurrentCulture.Name, CultureInfo.CurrentUICulture.Name ); var json = JsonConvert.SerializeObject(input); var obj = JsonConvert.DeserializeObject(json); _logger.LogInformation(currentLanguage.CultureName); //var ddd =await _identityUserLookupAppService.FindByIdAsync(new Guid("B3A4DE5A-0338-F82F-C71F-39FC33D8558A")); var existFaultGrade = await _faultGradeRepository.FirstOrDefaultAsync(p => p.FaultGradeNo == input.FaultGradeNo); if (existFaultGrade != null) { var aaa = _localizer["HelloWorld"]; var bbb = _localizer["FaultNoAlreadyExistsException", input.FaultGradeNo]; //throw new BusinessException("P000001", _localizer["FaultNoAlreadyExistsException", input.FaultGradeNo]); //throw new BusinessException("P00001", $"报警级别编号【{input.FaultGradeNo}】已存在"); throw new UserFriendlyException(_localizer["FaultNoAlreadyExistsException", input.FaultGradeNo]); } //var faultGrade = new FaultGrade( // input.FaultGradeNo, // input.FaultGradeName, // input.FaultGradeColor); //var result = await _faultGradeRepository.InsertAsync(faultGrade); //return ObjectMapper.Map<FaultGrade, FaultGradeDto>(result); var entity = ObjectMapper.Map <CreateFaultGradeInput, FaultGrade>(input); var result = await _faultGradeRepository.InsertAsync(entity); return(ObjectMapper.Map <FaultGrade, FaultGradeDto>(result)); }