public TimeZoneInfo GetUserTimeZone(UserEntity user) { TimeZoneInfo timeZoneInfo = null; if (_systemSettings.AllowUsersToSetTimeZone) { var timeZoneId = string.Empty; if (user != null) { timeZoneId = _userAttributeService.GetValue(user, UserAttribute.TimeZoneId, "", false, true); } if (PatternValidator.IsValidTimeZoneId(timeZoneId)) { timeZoneInfo = FindTimeZoneById(timeZoneId); } } return(timeZoneInfo ?? DefaultTimeZone); }
public static IChainableConstraint <IStringConstraints> IsTimeZoneId(this IStringConstraints constraints, bool ignoreEmpty = true) { return(constraints.Satisfy(v => (ignoreEmpty && string.IsNullOrEmpty(v)) || PatternValidator.IsValidTimeZoneId(v))); }