private object ResolveValue(bool updatingBase, bool setToDefaultValue, ceLiveCasinoTableBase tableBase, ceLiveCasinoTable tableDomain, string column, object value, object defaultValue, bool useBaseValueAsDefault, out bool changed, PropertyEditType editType = PropertyEditType.Override) { changed = false; if (CeLiveCasinoTableBaseProperties == null) { Type typeGameBase = typeof(ceLiveCasinoTableBase); CeLiveCasinoTableBaseProperties = typeGameBase.GetProperties(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public); } if (CeLiveCasinoTableProperties == null) { Type typeGameDomain = typeof(ceLiveCasinoTable); CeLiveCasinoTableProperties = typeGameDomain.GetProperties(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public); } PropertyInfo propertyGameBase = CeLiveCasinoTableBaseProperties.FirstOrDefault(f => f.Name.Equals(column)); if (propertyGameBase != null) { if (updatingBase) { object sourcesValue = propertyGameBase.GetValue(tableBase, null); if (sourcesValue == null || !sourcesValue.ToString().Equals(value.ToString(), StringComparison.OrdinalIgnoreCase)) { changed = true; } } else { PropertyInfo propertyGameDomain = CeLiveCasinoTableProperties.FirstOrDefault(f => f.Name.Equals(column)); if (propertyGameDomain != null) { object sourcesValue = propertyGameBase.GetValue(tableBase, null); if (setToDefaultValue) { value = sourcesValue; changed = true; } else if (sourcesValue != null && sourcesValue.ToString().Equals(value.ToString(), StringComparison.OrdinalIgnoreCase)) { value = useBaseValueAsDefault ? sourcesValue : defaultValue; changed = true; } else { if (tableDomain != null) { sourcesValue = propertyGameDomain.GetValue(tableDomain, null); if (sourcesValue == null || !sourcesValue.ToString().Equals(value.ToString(), StringComparison.OrdinalIgnoreCase)) { changed = true; } } else { changed = true; } } } } } return(value); }
private bool InternalUpdateProperty(long id, AvailableEditTableProperty property, object value, bool updatingBase, PropertyEditType editType, bool setToDefault) { if (updatingBase && setToDefault) { return(false); } bool succeed = false; using (DbManager db = new DbManager()) { db.BeginTransaction(); try { LiveCasinoTableAccessor lcta = LiveCasinoTableAccessor.CreateInstance <LiveCasinoTableAccessor>(db); SqlQuery <ceLiveCasinoTableBase> query = new SqlQuery <ceLiveCasinoTableBase>(db); ceLiveCasinoTableBase tableBase = null; ceLiveCasinoTable tableDomain = null; if (id > 0) { tableBase = query.SelectByKey(id); if (tableBase != null) { string column = string.Empty; object defaultValue = null; bool useBaseValueAsDefault = false; if (!updatingBase) { tableDomain = lcta.GetTable(DomainManager.CurrentDomainID, id); } bool isExist = tableDomain != null; #region Resolve and assignment property bool tempBool; column = property.ToString(); bool valueVerified = setToDefault; bool changed = true; bool valueResolved = false; switch (property) { #region bool properies case AvailableEditTableProperty.OpVisible: case AvailableEditTableProperty.Enabled: case AvailableEditTableProperty.NewTable: case AvailableEditTableProperty.TurkishTable: case AvailableEditTableProperty.VIPTable: useBaseValueAsDefault = true; if (!setToDefault) { if (bool.TryParse(value as string, out tempBool)) { valueVerified = true; value = tempBool; } } break; #endregion bool properies default: column = null; changed = false; break; } if (!valueResolved && !string.IsNullOrWhiteSpace(column)) { value = ResolveValue(updatingBase, setToDefault, tableBase, tableDomain, column, value, defaultValue, useBaseValueAsDefault, out changed); } #endregion Resolve and assignment property if (changed) { succeed = true; if (updatingBase) { LiveCasinoTableAccessor.UpdateTableBaseProperty(column, value, tableBase.ID); } else { SqlQuery <ceCasinoGame> query2 = new SqlQuery <ceCasinoGame>(db); if (isExist) { LiveCasinoTableAccessor.UpdateTableProperty(column, value, tableDomain.ID); } else { LiveCasinoTableAccessor.InsertNewTableWithSpecificProperty(DomainManager.CurrentDomainID , tableBase.ID , CurrentUserSession.SessionID , CurrentUserSession.UserID , column , value , tableBase.Enabled , tableBase.OpVisible ); } } } } } db.CommitTransaction(); return(succeed); } catch (Exception ex) { Logger.Exception(ex); db.RollbackTransaction(); } } return(false); }