예제 #1
0
        /// <summary>
        /// This method retrieves the most up-to-date list of contests from the database.
        /// </summary>
        /// <returns>True if success, false otherwise.</returns>
        public async Task <bool> RefreshContestsAdminAsync()
        {
            // Load the contest that the users has part in from the Database
            string query = "SELECT id_contest, contest_name, descript, start_date, limit_date, voting_limit_date " +
                           "FROM contest_table";

            SqlCommand cmd = DBSqlHelper.Connection.CreateCommand();

            cmd.CommandText = query;

            // Execute query
            using (DbDataReader reader = await cmd.ExecuteReaderAsync())
            {
                // Check if contest exists
                if (reader.HasRows)
                {
                    ContestDetails.Clear();

                    while (await reader.ReadAsync())
                    {
                        ContestDetails contest = new ContestDetails((int)reader[0], reader[1].ToString(), reader[2].ToString(), (DateTime)reader[3], (DateTime)reader[4], (DateTime)reader[5], false, false, false);
                        ContestDetails.Add(contest);
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// This method retrieves the most up-to-date list of contests from the database.
        /// </summary>
        /// <returns>True if success, false otherwise.</returns>
        public async Task <bool> RefreshContestsAsync()
        {
            // Load the contest that the users has part in from the Database
            string query = "SELECT id_contest, contest_name, descript, start_date, limit_date, voting_limit_date " +
                           "FROM contest_table " +
                           "WHERE id_contest IN( " +
                           "SELECT id_contest FROM contest_juri_table contest " +
                           "WHERE id_user = @id_user)";

            SqlCommand cmd = DBSqlHelper.Connection.CreateCommand();

            cmd.CommandText = query;

            SqlParameter sqlUserId = new SqlParameter("id_user", SqlDbType.Int);

            sqlUserId.Value = this.LoggedInUser.Id;
            cmd.Parameters.Add(sqlUserId);

            // Execute query
            using (DbDataReader reader = await cmd.ExecuteReaderAsync())
            {
                // Check if contest exists
                if (reader.HasRows)
                {
                    ContestDetails.Clear();

                    while (await reader.ReadAsync())
                    {
                        ContestDetails contest = new ContestDetails((int)reader[0], reader[1].ToString(), reader[2].ToString(), (DateTime)reader[3], (DateTime)reader[4], (DateTime)reader[5], false, false, false);
                        ContestDetails.Add(contest);
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }