Exemplo n.º 1
0
        /// <summary>
        /// Saves the specified clan in the specified database.
        /// </summary>
        /// <param name="Clan">The clan.</param>
        /// <param name="DBMS">The DBMS.</param>
        internal void Save(Alliance Clan, DBMS DBMS = Constants.Database)
        {
            switch (DBMS)
            {
            case DBMS.MySQL:
            {
                using (GBS_MySQL Database = new GBS_MySQL())
                {
                    Core.Database.Models.MySQL.Clans Data = Database.Clans.Find(Clan.HighID, Clan.LowID);

                    if (Data != null)
                    {
                        Data.Data = JsonConvert.SerializeObject(Clan, this.Settings);
                    }

                    Database.SaveChangesAsync();
                }

                break;
            }

            case DBMS.Redis:
            {
                Redis.Clans.StringSetAsync(Clan.ToString(), JsonConvert.SerializeObject(Clan, this.Settings), TimeSpan.FromMinutes(15));

                break;
            }

            case DBMS.Both:
            {
                this.Save(Clan, DBMS.MySQL);
                this.Save(Clan, DBMS.Redis);
                break;
            }

            case DBMS.Mongo:
            {
                Mongo.Clans.UpdateOneAsync(T => T.HighID == Clan.HighID && T.LowID == Clan.LowID, Builders <Core.Database.Models.Mongo.Clans> .Update.Set(T => T.Data, BsonDocument.Parse(JsonConvert.SerializeObject(Clan, this.Settings))));

                break;
            }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Saves the specified clan in the specified database.
        /// </summary>
        /// <param name="Clan">The clan.</param>
        /// <param name="DBMS">The DBMS.</param>
        internal void Save(Clan Clan, DBMS DBMS = Constants.Database)
        {
            switch (DBMS)
            {
            case DBMS.MySQL:
            {
                using (GBS_MySQL Database = new GBS_MySQL())
                {
                    Core.Database.Models.MySQL.Clans Data = Database.Clans.Find(Clan.HighID, Clan.LowID);

                    if (Data != null)
                    {
                        Data.Data = JsonConvert.SerializeObject(Clan, this.Settings);
                    }

                    Database.SaveChangesAsync();
                }

                break;
            }

            case DBMS.Redis:
            {
                Redis.Clans.StringSetAsync(Clan.ToString(), JsonConvert.SerializeObject(Clan, this.Settings), TimeSpan.FromMinutes(15));

                break;
            }

            case DBMS.Both:
            {
                this.Save(Clan, DBMS.MySQL);
                this.Save(Clan, DBMS.Redis);
                break;
            }
            }
        }