public ActionResult SaveTable(ceLiveCasinoTableBaseEx updatedTable , HttpPostedFileBase thumbnailFile ) { if (!DomainManager.AllowEdit()) { throw new Exception("Data modified is not allowed"); } try { string imageFileName; byte[] imageBuffer; if (ImageAsset.ParseImage(thumbnailFile, out imageFileName, out imageBuffer)) { imageFileName = ImageAsset.GetImageFtpFilePath(imageFileName); FTP.UploadFile(DomainManager.CurrentDomainID, imageFileName, imageBuffer); } SqlQuery <ceLiveCasinoTableBase> query = new SqlQuery <ceLiveCasinoTableBase>(); ceLiveCasinoTableBase baseTable = query.SelectByKey(updatedTable.ID); ceCasinoGameBaseEx game = CasinoGameAccessor.GetDomainGame(Constant.SystemDomainID, baseTable.CasinoGameBaseID); if (CurrentUserSession.IsSystemUser && DomainManager.CurrentDomainID == Constant.SystemDomainID) { baseTable.TableName = updatedTable.TableName; baseTable.Category = updatedTable.Category; baseTable.ExtraParameter1 = updatedTable.ExtraParameter1; baseTable.ExtraParameter2 = updatedTable.ExtraParameter2; baseTable.ExtraParameter3 = updatedTable.ExtraParameter3; baseTable.ExtraParameter4 = updatedTable.ExtraParameter4; baseTable.LaunchParams = updatedTable.LaunchParams; baseTable.OpenHoursStart = updatedTable.OpenHoursStart; baseTable.OpenHoursEnd = updatedTable.OpenHoursEnd; baseTable.OpenHoursTimeZone = updatedTable.OpenHoursTimeZone; baseTable.Limit = ParseLimit(); baseTable.VIPTable = updatedTable.VIPTable; baseTable.NewTable = updatedTable.NewTable; baseTable.NewTableExpirationDate = updatedTable.NewTable ? updatedTable.NewTableExpirationDate : DateTime.Now.AddDays(-1); baseTable.ExcludeFromRandomLaunch = updatedTable.ExcludeFromRandomLaunch; baseTable.TurkishTable = updatedTable.TurkishTable; baseTable.BetBehindAvailable = updatedTable.BetBehindAvailable; baseTable.SeatsUnlimited = updatedTable.SeatsUnlimited; baseTable.DealerGender = updatedTable.DealerGender; baseTable.DealerOrigin = updatedTable.DealerOrigin; baseTable.TableStudioUrl = updatedTable.TableStudioUrl; //if (game.VendorID == VendorID.EvolutionGaming) { baseTable.ClientCompatibility = updatedTable.ClientCompatibility; } if (!string.IsNullOrWhiteSpace(imageFileName)) { baseTable.Thumbnail = imageFileName; } query.Update(baseTable); //updating properties that are inherited from basetable and disabled for edit in child tables var propertiesValues = new Dictionary <string, object> { { "BetBehindAvailable", updatedTable.BetBehindAvailable }, { "SeatsUnlimited", updatedTable.SeatsUnlimited }, { "DealerGender", updatedTable.DealerGender }, { "DealerOrigin", updatedTable.DealerOrigin } }; LiveCasinoTableAccessor.UpdateChildTablesProperties(propertiesValues, baseTable.ID); } else if (DomainManager.CurrentDomainID != Constant.SystemDomainID) { LiveCasinoTableAccessor lta = LiveCasinoTableAccessor.CreateInstance <LiveCasinoTableAccessor>(); ceLiveCasinoTable table = lta.GetTable(DomainManager.CurrentDomainID, updatedTable.ID); bool isExist = table != null; bool isModified = false; if (!isExist) { table = new ceLiveCasinoTable() { DomainID = DomainManager.CurrentDomainID, LiveCasinoTableBaseID = updatedTable.ID }; table.Ins = DateTime.Now; table.SessionUserID = CurrentUserSession.UserID; table.SessionID = CurrentUserSession.UserSessionID; table.OpVisible = baseTable.OpVisible; table.ClientCompatibility = null; table.NewTableExpirationDate = baseTable.NewTableExpirationDate == DateTime.MinValue ? DateTime.Now.Date.AddDays(-1) : baseTable.NewTableExpirationDate; table.BetBehindAvailable = baseTable.BetBehindAvailable; table.SeatsUnlimited = baseTable.SeatsUnlimited; table.DealerGender = baseTable.DealerGender; table.DealerOrigin = baseTable.DealerOrigin; } table.ShortName = null; table.Logo = null; table.BackgroundImage = null; if (!string.IsNullOrWhiteSpace(updatedTable.ExtraParameter1) && !string.Equals(baseTable.ExtraParameter1, updatedTable.ExtraParameter1)) { isModified = true; table.ExtraParameter1 = updatedTable.ExtraParameter1; } else { table.ExtraParameter1 = null; } if (!string.IsNullOrWhiteSpace(updatedTable.ExtraParameter2) && !string.Equals(baseTable.ExtraParameter2, updatedTable.ExtraParameter2)) { isModified = true; table.ExtraParameter2 = updatedTable.ExtraParameter2; } else { table.ExtraParameter2 = null; } if (!string.IsNullOrWhiteSpace(updatedTable.ExtraParameter3) && !string.Equals(baseTable.ExtraParameter3, updatedTable.ExtraParameter3)) { isModified = true; table.ExtraParameter3 = updatedTable.ExtraParameter3; } else { table.ExtraParameter3 = null; } if (!string.IsNullOrWhiteSpace(updatedTable.ExtraParameter4) && !string.Equals(baseTable.ExtraParameter4, updatedTable.ExtraParameter4)) { isModified = true; table.ExtraParameter4 = updatedTable.ExtraParameter4; } else { table.ExtraParameter4 = null; } if (!string.IsNullOrEmpty(updatedTable.LaunchParams) && !string.Equals(baseTable.LaunchParams, updatedTable.LaunchParams)) { isModified = true; table.LaunchParams = updatedTable.LaunchParams; } else { table.LaunchParams = null; } if (!string.IsNullOrWhiteSpace(updatedTable.TableName) && !string.Equals(baseTable.TableName, updatedTable.TableName)) { isModified = true; table.TableName = updatedTable.TableName; } else { table.TableName = null; } if (!string.IsNullOrWhiteSpace(updatedTable.Category) && !string.Equals(baseTable.Category, updatedTable.Category)) { isModified = true; table.Category = updatedTable.Category; } else { table.Category = null; } if (!string.IsNullOrWhiteSpace(imageFileName) && !string.Equals(baseTable.Thumbnail, updatedTable.Thumbnail)) { isModified = true; table.Thumbnail = imageFileName; } else { table.Thumbnail = null; } //if (game.VendorID == VendorID.EvolutionGaming) { if (updatedTable.ClientCompatibility != null && !string.Equals(table.ClientCompatibility, updatedTable.ClientCompatibility)) { isModified = true; if (!string.Equals(baseTable.ClientCompatibility, updatedTable.ClientCompatibility)) { table.ClientCompatibility = updatedTable.ClientCompatibility; } else { table.ClientCompatibility = null; } } } string limitationXml = table.LimitationXml; LiveCasinoTableLimit limit = table.Limit; table.Limit = ParseLimit(); if (table.Limit.Equals(baseTable.Limit)) { table.LimitationXml = null; } if (!(string.IsNullOrWhiteSpace(table.LimitationXml) && string.IsNullOrWhiteSpace(limitationXml))) { if (table.LimitationXml == null) { isModified = true; } else if (!table.LimitationXml.Equals(limitationXml, StringComparison.InvariantCultureIgnoreCase)) { isModified = true; } } if (table.VIPTable != updatedTable.VIPTable) { table.VIPTable = updatedTable.VIPTable; isModified = true; } if (table.NewTable != updatedTable.NewTable || table.NewTableExpirationDate.CompareTo(updatedTable.NewTableExpirationDate) != 0) { table.NewTable = updatedTable.NewTable; table.NewTableExpirationDate = updatedTable.NewTable ? updatedTable.NewTableExpirationDate : DateTime.Now.AddDays(-1); isModified = true; } if (table.TurkishTable != updatedTable.TurkishTable) { table.TurkishTable = updatedTable.TurkishTable; isModified = true; } if (table.ExcludeFromRandomLaunch != updatedTable.ExcludeFromRandomLaunch) { table.ExcludeFromRandomLaunch = updatedTable.ExcludeFromRandomLaunch; isModified = true; } if (table.TableStudioUrl != updatedTable.TableStudioUrl) { table.TableStudioUrl = updatedTable.TableStudioUrl; isModified = true; } if (isModified) { SqlQuery <ceLiveCasinoTable> query2 = new SqlQuery <ceLiveCasinoTable>(); if (isExist) { query2.Update(table); } else { query2.Insert(table); } } } return(this.Json(new { success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Logger.Exception(ex); return(this.Json(new { success = false, error = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ContentResult Save(ceContentProviderBase updatedProvider , HttpPostedFileBase logoFile) { if (!DomainManager.AllowEdit()) { throw new Exception("Data modified is not allowed"); } try { string logoImageFilePath = null; string imageFileName; byte[] imageBuffer; if (ImageAsset.ParseImage(logoFile, out imageFileName, out imageBuffer)) { logoImageFilePath = ImageAsset.GetImageFtpFilePath(imageFileName); FTP.UploadFile(DomainManager.CurrentDomainID, logoImageFilePath, imageBuffer); } using (DbManager db = new DbManager()) { if (DomainManager.CurrentDomainID == Constant.SystemDomainID) { if (string.IsNullOrWhiteSpace(updatedProvider.Identifying)) { throw new ArgumentNullException("Identifying"); } if (string.IsNullOrWhiteSpace(updatedProvider.Name)) { throw new ArgumentNullException("Name"); } if (!string.IsNullOrWhiteSpace(updatedProvider.Name)) { updatedProvider.Name = Regex.Replace(updatedProvider.Name, @"[^a-z_\-\d]", string.Empty, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.ECMAScript | RegexOptions.Compiled); if (Regex.IsMatch(updatedProvider.Name, "^(\\d+)$", RegexOptions.CultureInvariant | RegexOptions.Compiled)) { throw new Exception("The name can not only contain digits."); } } SqlQuery <ceContentProviderBase> query = new SqlQuery <ceContentProviderBase>(db); ceContentProviderBase provider = null; if (updatedProvider.ID > 0) { provider = query.SelectByKey(updatedProvider.ID); } if (provider == null) { provider = new ceContentProviderBase(); provider.Ins = DateTime.Now; provider.Enabled = true; } bool changed = false; if (string.IsNullOrWhiteSpace(provider.Identifying) && provider.Identifying != updatedProvider.Identifying) { provider.Identifying = updatedProvider.Identifying; changed = true; } if (provider.Name != updatedProvider.Name) { provider.Name = updatedProvider.Name; changed = true; } if (!string.IsNullOrWhiteSpace(logoImageFilePath)) { if (provider.Logo != logoImageFilePath) { provider.Logo = logoImageFilePath; changed = true; } } if (provider.ID > 0) { if (changed) { query.Update(db, provider); } } else { query.Insert(db, provider); } } else if (updatedProvider.ID > 0) { SqlQuery <ceContentProviderBase> queryBase = new SqlQuery <ceContentProviderBase>(db); ceContentProviderBase providerBase = queryBase.SelectByKey(updatedProvider.ID); SqlQuery <ceContentProvider> query = new SqlQuery <ceContentProvider>(db); ContentProviderAccessor cpa = ContentProviderAccessor.CreateInstance <ContentProviderAccessor>(); ceContentProvider provider = cpa.QueryDomainProvider(updatedProvider.ID, DomainManager.CurrentDomainID); if (provider == null) { provider = new ceContentProvider(); provider.ContentProviderBaseID = providerBase.ID; provider.Enabled = null; provider.Ins = DateTime.Now; provider.Logo = null; provider.DomainID = DomainManager.CurrentDomainID; } bool changed = false; if (!string.IsNullOrWhiteSpace(logoImageFilePath)) { if (providerBase.Logo != updatedProvider.Logo) { provider.Logo = logoImageFilePath; } else { provider.Logo = null; } changed = true; } if (provider.ID > 0) { if (changed) { query.Update(db, provider); } } else { query.Insert(db, provider); } } } string script = "<script language=\"javascript\" type=\"text/javascript\">top.onSaved(true, '');</script>"; return(this.Content(script, "text/html")); } catch (Exception ex) { Logger.Exception(ex); string script = string.Format("<script language=\"javascript\" type=\"text/javascript\">top.onSaved(false, '{0}');</script>", ex.Message.SafeJavascriptStringEncode()); return(this.Content(script, "text/html")); } }