protected virtual string DisplayName(PropertyInfo propertyInfo) { if (propertyInfo == null) { return(string.Empty); } var conn = new RepositoryInjection().GetClass <IFactoryConnection>(); var translate = new TranslateApp(conn); var displayName = string.Empty; try { var t = GlobalUser.Translates.FirstOrDefault(c => c.PropertyName == Name); if (t == null) { translate.InsertOrUpdate(new Translate() { PropertyName = Name, Portugues = GetAttribute <DisplayNameAttribute>(propertyInfo).DisplayName, CompanyControlId = GlobalUser.Company.Id, UserControlId = GlobalUser.User.Id }); conn.Save(); } else { var newDisplayName = GetAttribute <DisplayNameAttribute>(propertyInfo).DisplayName; if (newDisplayName != t.Portugues) { t.Portugues = newDisplayName; translate.InsertOrUpdate(t); conn.Save(); } displayName = t.Portugues; } } catch (Exception) { // ignored } var display = !string.IsNullOrEmpty(Caption) ? Caption : !string.IsNullOrEmpty(displayName) ? displayName : GetAttribute <DisplayNameAttribute>(propertyInfo)?.DisplayName; return(display); }
public bool Save(Translate Translate) { _TranslateApp.InsertOrUpdate(Translate); return(_connection.Save()); }