Example #1
0
        /// <summary>
        /// Carrega o artigo pelo id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static List <ProfileMedals> LoadAllFrom(Profile p)
        {
            List <ProfileMedals> lst = new List <ProfileMedals>();

            SqlCommand sel = new SqlCommand();

            sel.CommandText = "SELECT medalid, awarded FROM " + Base.conf.prefix + "[newsprofilemedals] WHERE userid=@userid";
            sel.Parameters.Add(new SqlParameter("@userid", p.user.id));

            sel.Connection = Base.conf.Open();
            SqlDataReader rdr = sel.ExecuteReader();

            while (rdr.Read())
            {
                // Pega as informações

                ProfileMedals pm = new ProfileMedals(p);

                pm.medalsId   = rdr.GetString(0);
                pm.awardedInt = rdr.GetDateTime(1);

                lst.Add(pm);
            }

            rdr.Close();
            sel.Connection.Close();

            return(lst);
        }
Example #2
0
        /// <summary>
        /// Verifica se as medalhas estão ok
        /// </summary>
        public void CheckMedals(Medal.Dimension d)
        {
            List <Medal> lst = Medal.AllMedalsForPoints(d, GetPointNumberForDimensions(d));

            for (int i = 0; i < lst.Count; i++)
            {
                ProfileMedals pm = GetProfileMedal(lst[i].id);
                if (pm == null)
                {
                    pm          = new ProfileMedals(this);
                    pm.medalsId = lst[i].id;
                    pm.awarded  = DateTime.Now;
                    pm.Save();

                    medals.Add(pm);
                }
            }
        }