public void IsReAgreeTest_InfoIsEmpty(TermsType termsType) { var termsUpdateService = CreateService(); var result = termsUpdateService.IsReAgree(termsType, new TermsUpdateInfoModel()); Assert.False(result); }
public async Task Migrate(TermsType termsType, bool isAgree) { loggerService.StartMethod(); var applicationPropertyKey = termsType == TermsType.TermsOfService ? TermsOfServiceLastUpdateDateKey : PrivacyPolicyLastUpdateDateKey; var preferenceKey = termsType == TermsType.TermsOfService ? PreferenceKey.TermsOfServiceLastUpdateDateTime : PreferenceKey.PrivacyPolicyLastUpdateDateTime; if (preferencesService.ContainsKey(applicationPropertyKey)) { return; } if (isAgree) { if (applicationPropertyService.ContainsKey(applicationPropertyKey)) { var lastUpdateDate = (DateTime)applicationPropertyService.GetProperties(applicationPropertyKey); preferencesService.SetValue(preferenceKey, lastUpdateDate); } else { preferencesService.SetValue(preferenceKey, new DateTime()); } } await applicationPropertyService.Remove(applicationPropertyKey); loggerService.EndMethod(); }
public bool IsUpdated(TermsType termsType, TermsUpdateInfoModel termsUpdateInfo) { loggerService.StartMethod(); TermsUpdateInfoModel.Detail info = termsType switch { TermsType.TermsOfService => termsUpdateInfo.TermsOfService, TermsType.PrivacyPolicy => termsUpdateInfo.PrivacyPolicy, _ => throw new NotSupportedException() }; if (info == null) { loggerService.EndMethod(); return(false); } var updateDatetime = info.UpdateDateTimeUtc; DateTime lastUpdateDate = userDataRepository.GetLastUpdateDate(termsType); loggerService.Info($"termsType: {termsType}, lastUpdateDate: {lastUpdateDate}, updateDatetimeUtc: {updateDatetime}"); loggerService.EndMethod(); return(lastUpdateDate < updateDatetime); } }
private async Task MigrateTermAsync(TermsType termsType, bool isAgree) { _loggerService.StartMethod(); var applicationPropertyKey = termsType == TermsType.TermsOfService ? APPLICATION_PROPERTY_TERMS_OF_SERVICE_LAST_UPDATE_DATE_KEY : APPLICATION_PROPERTY_PRIVACY_POLICY_LAST_UPDATE_DATE_KEY; var preferenceKey = termsType == TermsType.TermsOfService ? PREFERENCE_KEY_TERMS_OF_SERVICE_LAST_UPDATE_DATETIME : PREFERENCE_KEY_PRIVACY_POLICY_LAST_UPDATE_DATETIME; if (_preferencesService.ContainsKey(applicationPropertyKey)) { _loggerService.EndMethod(); return; } if (isAgree) { if (_applicationPropertyService.ContainsKey(applicationPropertyKey)) { var lastUpdateDate = _applicationPropertyService.GetProperties(applicationPropertyKey).ToString(); _preferencesService.SetValue(preferenceKey, lastUpdateDate); } else { _preferencesService.SetValue(preferenceKey, new DateTime().ToString()); _loggerService.Info($"Migrated {applicationPropertyKey}"); } } await _applicationPropertyService.Remove(applicationPropertyKey); _loggerService.EndMethod(); }
public async Task SaveLastUpdateDateAsync(TermsType termsType, DateTime updateDate) { loggerService.StartMethod(); var key = termsType == TermsType.TermsOfService ? TermsOfServiceLastUpdateDateKey : PrivacyPolicyLastUpdateDateKey; await applicationPropertyService.SavePropertiesAsync(key, updateDate); loggerService.EndMethod(); }
public void SaveLastUpdateDate(TermsType termsType, DateTime updateDate) { loggerService.StartMethod(); var key = termsType == TermsType.TermsOfService ? PreferenceKey.TermsOfServiceLastUpdateDateTime : PreferenceKey.PrivacyPolicyLastUpdateDateTime; preferencesService.SetValue(key, updateDate); loggerService.EndMethod(); }
public TermDetail(int debtCode, TermsType name, ITerm term) { Id = ObjectId.GenerateNewId().ToString(); SetDebtCode(debtCode); SerTermTypeName(name); SetTerm(term); Active = true; Deleted = false; RowVersion = new byte[0]; }
public void SaveLastUpdateDate(TermsType termsType, DateTime updateDate) { _loggerService.StartMethod(); var key = termsType == TermsType.TermsOfService ? PreferenceKey.TermsOfServiceLastUpdateDateTimeEpoch : PreferenceKey.PrivacyPolicyLastUpdateDateTimeEpoch; _preferencesService.SetValue(key, updateDate.ToUnixEpoch()); _loggerService.EndMethod(); }
public DateTime GetLastUpdateDate(TermsType termsType) { string key = termsType switch { TermsType.TermsOfService => PreferenceKey.TermsOfServiceLastUpdateDateTimeEpoch, TermsType.PrivacyPolicy => PreferenceKey.PrivacyPolicyLastUpdateDateTimeEpoch, _ => throw new NotSupportedException() }; long epoch = _preferencesService.GetValue(key, 0L); return(DateTime.UnixEpoch.AddSeconds(epoch)); }
public void IsUpdatedTest_RequiredReAgree(TermsType termsType, string key) { var info = new TermsUpdateInfoModel { TermsOfService = new TermsUpdateInfoModel.Detail { UpdateDateTimeJst = new DateTime(2020, 11, 2) }, PrivacyPolicy = new TermsUpdateInfoModel.Detail { UpdateDateTimeJst = new DateTime(2020, 11, 2) } }; var termsUpdateService = CreateService(); mockPreferencesService.Setup(x => x.ContainsKey(key)).Returns(true); mockUserDataRepository.Setup(x => x.GetLastUpdateDate(termsType)).Returns(new DateTime(2020, 11, 1)); var result = termsUpdateService.IsUpdated(termsType, info); Assert.True(result); }
public void IsReAgreeTest_RequiredReAgree(TermsType termsType, string key) { var info = new TermsUpdateInfoModel { TermsOfService = new TermsUpdateInfoModel.Detail { UpdateDateTime = new DateTime(2020, 11, 2) }, PrivacyPolicy = new TermsUpdateInfoModel.Detail { UpdateDateTime = new DateTime(2020, 11, 2) } }; var termsUpdateService = CreateService(); mockApplicationPropertyService.Setup(x => x.ContainsKey(key)).Returns(true); mockApplicationPropertyService.Setup(x => x.GetProperties(key)).Returns(new DateTime(2020, 11, 1)); var result = termsUpdateService.IsReAgree(termsType, info); Assert.True(result); }
public bool IsReAgree(TermsType termsType, TermsUpdateInfoModel termsUpdateInfo) { loggerService.StartMethod(); TermsUpdateInfoModel.Detail info = null; string key = null; switch (termsType) { case TermsType.TermsOfService: info = termsUpdateInfo.TermsOfService; key = PreferenceKey.TermsOfServiceLastUpdateDateTime; break; case TermsType.PrivacyPolicy: info = termsUpdateInfo.PrivacyPolicy; key = PreferenceKey.PrivacyPolicyLastUpdateDateTime; break; } if (info == null) { loggerService.EndMethod(); return(false); } var lastUpdateDate = new DateTime(); if (preferencesService.ContainsKey(key)) { lastUpdateDate = preferencesService.GetValue(key, lastUpdateDate); } loggerService.Info($"termsType: {termsType}, lastUpdateDate: {lastUpdateDate}, info.UpdateDateTime: {info.UpdateDateTime}"); loggerService.EndMethod(); return(lastUpdateDate < info.UpdateDateTime); }
public bool IsReAgree(TermsType privacyType, TermsUpdateInfoModel termsUpdateInfo) { loggerService.StartMethod(); TermsUpdateInfoModel.Detail info = null; string key = null; switch (privacyType) { case TermsType.TermsOfService: info = termsUpdateInfo.TermsOfService; key = TermsOfServiceLastUpdateDateKey; break; case TermsType.PrivacyPolicy: info = termsUpdateInfo.PrivacyPolicy; key = PrivacyPolicyLastUpdateDateKey; break; } if (info == null) { loggerService.EndMethod(); return(false); } var lastUpdateDate = new DateTime(); if (applicationPropertyService.ContainsKey(key)) { lastUpdateDate = (DateTime)applicationPropertyService.GetProperties(key); } loggerService.Info($"privacyType: {privacyType}, lastUpdateDate: {lastUpdateDate}, info.UpdateDateTime: {info.UpdateDateTime}"); loggerService.EndMethod(); return(lastUpdateDate < info.UpdateDateTime); }
public bool IsUpdated(TermsType termsType, TermsUpdateInfoModel termsUpdateInfo) { bool result = false; switch (termsType) { case TermsType.TermsOfService: if (_termsOfServiceUpdated) { _termsOfServiceUpdated = false; result = true; } break; case TermsType.PrivacyPolicy: if (_privacyPolicyUpdated) { _privacyPolicyUpdated = false; result = true; } break; } return(result); }
private async Task MigrateTermAsync(TermsType termsType, bool isAgree) { _loggerService.StartMethod(); var applicationPropertyKey = termsType == TermsType.TermsOfService ? APPLICATION_PROPERTY_TERMS_OF_SERVICE_LAST_UPDATE_DATE_KEY : APPLICATION_PROPERTY_PRIVACY_POLICY_LAST_UPDATE_DATE_KEY; var preferenceKey = termsType == TermsType.TermsOfService ? PREFERENCE_KEY_TERMS_OF_SERVICE_LAST_UPDATE_DATETIME : PREFERENCE_KEY_PRIVACY_POLICY_LAST_UPDATE_DATETIME; if (_preferencesService.ContainsKey(applicationPropertyKey)) { _loggerService.EndMethod(); return; } if (isAgree) { if (_applicationPropertyService.ContainsKey(applicationPropertyKey)) { var lastUpdateDate = _applicationPropertyService.GetProperties(applicationPropertyKey).ToString(); _preferencesService.SetStringValue(preferenceKey, lastUpdateDate); } else { /// **WARNING** /// `new DateTime()` means `DateTime.MinValue`, it equals `0001/01/01 00:00:00`. /// For converting timezone, please use `TimeZoneInfo.ContertTimeTo*`. /// Do not use direct calculation (e.g. subtract `TimeSpan.FromHours(9)` from `DateTime.MinValue`) /// because it cause an ArgumentOutOfRangeException. _preferencesService.SetStringValue(preferenceKey, new DateTime().ToString()); _loggerService.Info($"Migrated {applicationPropertyKey}"); } } await _applicationPropertyService.Remove(applicationPropertyKey); _loggerService.EndMethod(); }
/// <summary> /// コンストラクタ /// </summary> public TermsTypeData(TermsType termsType) { this.TermsType = termsType; }