コード例 #1
0
        /// <summary>
        /// The object factory for a particular data collection instance.
        /// </summary>
        public virtual void CreateObjectsFromData(TitleHolders titleholders, System.Data.DataSet data)
        {
            // Do nothing if we have nothing
            if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
            {
                return;
            }


            // Create a local variable for the new instance.
            TitleHolder newobj = null;

            // Create a local variable for the data row instance.
            System.Data.DataRow dr = null;


            // Iterate through the table rows
            for (int i = 0; i < data.Tables[0].Rows.Count; i++)
            {
                // Get a reference to the data row
                dr = data.Tables[0].Rows[i];
                // Create a new object instance
                newobj = System.Activator.CreateInstance(titleholders.ContainsType[0]) as TitleHolder;
                // Let the instance set its own members
                newobj.SetMembers(ref dr);
                // Add the new object to the collection instance
                titleholders.Add(newobj);
            }
        }
コード例 #2
0
        /// <summary>
        /// Fill method for populating an entire collection of TitleHolders
        /// </summary>
        public virtual void Fill(TitleHolders titleHolders)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(TitleHolder.GetConnectionString());


            try
            {
                using (cnn)
                {
                    // open the connection
                    cnn.Open();


                    // create an instance of the reader to fill.
                    SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectTitleHolders");


                    // Send the collection and data to the object factory
                    CreateObjectsFromData(titleHolders, datareader);


                    // close the connection
                    cnn.Close();
                }


                // nullify the connection
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
コード例 #3
0
        /// <summary>
        /// Gets the objects for the TITLE_HOLDER relationship.
        /// </summary>
        public TitleHolders GetTitleHolders()
        {
            TitleHolders titleholders = new TitleHolders();


            TitleHolderBase.ServiceObject.FillByLandTrustType(titleholders, _id);
            return(titleholders);
        }
コード例 #4
0
        /// <summary>
        /// Gets the objects for the TITLE_HOLDER relationship.
        /// </summary>
        public TitleHolders GetTitleHolders()
        {
            TitleHolders titleholders = new TitleHolders();


            TitleHolderBase.ServiceObject.FillByLoanApplication(titleholders, _id);
            return(titleholders);
        }
コード例 #5
0
        /// <summary>
        /// Gets all the available objects.
        /// </summary>
        public virtual TitleHolders GetAll()
        {
            // create a new instance of the return object
            TitleHolders objects = new TitleHolders();


            // fill the objects
            this.Fill(objects);


            // return the filled object from the service
            return(objects);
        }
コード例 #6
0
        /// <summary>
        /// Fill method for populating a collection by LOAN_APPLICATION
        /// </summary>
        public void FillByLoanApplication(TitleHolders titleHolders, System.Int64 id)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(TitleHolder.GetConnectionString());


            try
            {
                // discover the sql parameters
                SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(TitleHolder.GetConnectionString(), "gsp_SelectTitleHoldersByLoanApplication");


                using (cnn)
                {
                    // open the connection
                    cnn.Open();


                    // set the parameters
                    sqlparams["@loanApplicationId"].Value = id;


                    // create an instance of the reader to fill.
                    SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectTitleHoldersByLoanApplication", sqlparams);


                    // Send the collection and data to the object factory.
                    CreateObjectsFromData(titleHolders, datareader);


                    // close the connection
                    cnn.Close();
                }


                // nullify the connection
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
コード例 #7
0
        /// <summary>
        /// The object factory for a particular data collection instance.
        /// </summary>
        public virtual void CreateObjectsFromData(TitleHolders titleholders, System.Data.SqlClient.SqlDataReader data)
        {
            // Do nothing if we have nothing
            if (data == null)
            {
                return;
            }


            // Create a local variable for the new instance.
            TitleHolder newobj = null;

            // Iterate through the data reader
            while (data.Read())
            {
                // Create a new object instance
                newobj = System.Activator.CreateInstance(titleholders.ContainsType[0]) as TitleHolder;
                // Let the instance set its own members
                newobj.SetMembers(ref data);
                // Add the new object to the collection instance
                titleholders.Add(newobj);
            }
        }
コード例 #8
0
        public static void Initialize(FederationContext context)
        {
            context.Database.EnsureCreated();

            if (context.Players.Any())
            {
                return;
            }

            var players = new Players[]
            {
                new Players {
                    PL_NAME = "Magnus Carlsen", PL_RATING = 2842, PL_SEX = "M"
                },
                new Players {
                    PL_NAME = "Fabiano Caruana", PL_RATING = 2831, PL_SEX = "M"
                },
                new Players {
                    PL_NAME = "Judit Polgar", PL_RATING = 2630, PL_SEX = "F"
                },
                new Players {
                    PL_NAME = "Jio Huan", PL_RATING = 2672, PL_SEX = "F"
                },
                new Players {
                    PL_NAME = "Artem Denisenko", PL_RATING = 2084, PL_SEX = "M"
                },
                new Players {
                    PL_NAME = "This Old Dude", PL_RATING = 1712, PL_SEX = "M"
                },
                new Players {
                    PL_NAME = "Hikaru Nakamura", PL_RATING = 2802, PL_SEX = "M"
                },
                new Players {
                    PL_NAME = "Robert Hess", PL_RATING = 2611, PL_SEX = "M"
                }
            };

            foreach (Players p in players)
            {
                context.Players.Add(p);
            }
            context.SaveChanges();

            var tourneys = new Tournaments[]
            {
                new Tournaments {
                    TR_NAME = "World Championship 2018", TR_PRIZEPOOL = 10000000, TR_DATE_BEG = new DateTime(2018, 12, 1), TR_DATE_END = new DateTime(2018, 12, 15)
                },
                new Tournaments {
                    TR_NAME = "Tata Steel Chess", TR_PRIZEPOOL = 3000000, TR_DATE_BEG = new DateTime(2019, 1, 8), TR_DATE_END = new DateTime(2019, 1, 23)
                },
                new Tournaments {
                    TR_NAME = "Chicago Major", TR_PRIZEPOOL = 1000000, TR_DATE_BEG = new DateTime(2018, 10, 12), TR_DATE_END = new DateTime(2018, 11, 3)
                },
                new Tournaments {
                    TR_NAME = "Casters Battle", TR_PRIZEPOOL = 42000, TR_DATE_BEG = new DateTime(2018, 8, 3), TR_DATE_END = new DateTime(2018, 3, 17)
                },
                new Tournaments {
                    TR_NAME = "Blitz World Championship 2018", TR_PRIZEPOOL = 1500000, TR_DATE_BEG = new DateTime(2018, 7, 3), TR_DATE_END = new DateTime(2018, 7, 10)
                }
            };

            foreach (Tournaments t in tourneys)
            {
                context.Tournaments.Add(t);
            }
            context.SaveChanges();

            var games = new Games[]
            {
                new Games {
                    GM_NOTATION = "nocontext1"
                },
                new Games {
                    GM_NOTATION = "nocontext2"
                },
                new Games {
                    GM_NOTATION = "nocontext3"
                },
                new Games {
                    GM_NOTATION = "nocontext4"
                },
                new Games {
                    GM_NOTATION = "nocontext5"
                },
                new Games {
                    GM_NOTATION = "nocontext6"
                },
                new Games {
                    GM_NOTATION = "nocontext7"
                },
                new Games {
                    GM_NOTATION = "nocontext8"
                },
                new Games {
                    GM_NOTATION = "nocontext9"
                },
                new Games {
                    GM_NOTATION = "nocontext10"
                },
                new Games {
                    GM_NOTATION = "nocontext11"
                },
                new Games {
                    GM_NOTATION = "nocontext12"
                }
            };

            foreach (Games g in games)
            {
                context.Games.Add(g);
            }
            context.SaveChanges();

            var titles = new Titles[]
            {
                new Titles {
                    TTL_NAME = "World Champion"
                },
                new Titles {
                    TTL_NAME = "Female World Champion"
                },
                new Titles {
                    TTL_NAME = "Blitz World Champion"
                },
                new Titles {
                    TTL_NAME = "Nobody"
                }
            };

            foreach (Titles t in titles)
            {
                context.Titles.Add(t);
            }
            context.SaveChanges();

            var casters = new Casters[]
            {
                new Casters {
                    CST_NAME = "Robert Hess", CST_CREDIT = 96, CST_SEX = "M"
                },
                new Casters {
                    CST_NAME = "Daniel Melon", CST_CREDIT = 99, CST_SEX = "M"
                },
                new Casters {
                    CST_NAME = "Anna Melon", CST_CREDIT = 88, CST_SEX = "F"
                },
                new Casters {
                    CST_NAME = "Judit Polgar", CST_CREDIT = 44, CST_SEX = "F"
                },
            };

            foreach (Casters c in casters)
            {
                context.Casters.Add(c);
            }
            context.SaveChanges();

            var holders = new TitleHolders[]
            {
                new TitleHolders {
                    titleID = 1, playerID = 1
                },
                new TitleHolders {
                    titleID = 2, playerID = 4
                },
                new TitleHolders {
                    titleID = 3, playerID = 7
                },
                new TitleHolders {
                    titleID = 4, playerID = 5
                }
            };

            foreach (TitleHolders th in holders)
            {
                context.TitleHolders.Add(th);
            }
            context.SaveChanges();
        }