public async Task <VerifyRecordResult> UpdateAsync(SystemEnvironmentAdapterModel paraObject) { try { SystemEnvironment itemData = Mapper.Map <SystemEnvironment>(paraObject); CleanTrackingHelper.Clean <SystemEnvironment>(context); SystemEnvironment item = await context.SystemEnvironment .AsNoTracking() .FirstOrDefaultAsync(x => x.Id == paraObject.Id); if (item == null) { return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.無法修改紀錄)); } else { CleanTrackingHelper.Clean <SystemEnvironment>(context); context.Entry(itemData).State = EntityState.Modified; await context.SaveChangesAsync(); CleanTrackingHelper.Clean <SystemEnvironment>(context); return(VerifyRecordResultFactory.Build(true)); } } catch (Exception ex) { Logger.LogError(ex, "修改記錄發生例外異常"); return(VerifyRecordResultFactory.Build(false, "修改記錄發生例外異常", ex)); } }
public async Task GetPasswordHint() { if (systemEnvironmentAdapterModel == null) { systemEnvironmentAdapterModel = await SystemEnvironmentService.GetAsync(); } PasswordStrength passwordStrength = (PasswordStrength)systemEnvironmentAdapterModel.PasswordComplexity; PasswordHint = PasswordCheck.PasswordHint(passwordStrength); }
public async Task <VerifyRecordResult> AddAsync(SystemEnvironmentAdapterModel paraObject) { try { SystemEnvironment itemParameter = Mapper.Map <SystemEnvironment>(paraObject); CleanTrackingHelper.Clean <SystemEnvironment>(context); await context.SystemEnvironment .AddAsync(itemParameter); await context.SaveChangesAsync(); CleanTrackingHelper.Clean <SystemEnvironment>(context); return(VerifyRecordResultFactory.Build(true)); } catch (Exception ex) { Logger.LogError(ex, "新增記錄發生例外異常"); return(VerifyRecordResultFactory.Build(false, "新增記錄發生例外異常", ex)); } }