Esempio n. 1
0
        public void GetPracticesInObjective(string userId)
        {
            //Get Connection from config file
            string connString = System.Configuration.ConfigurationManager.
                                ConnectionStrings["killthetest"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(connString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand())
                {
                    command.Connection     = connection;
                    command.CommandTimeout = 0;
                    command.CommandType    = System.Data.CommandType.StoredProcedure;
                    command.CommandText    = "dbo.get_objective_Practices";
                    command.Parameters.AddWithValue("objective_id", ObjectiveId);

                    SqlDataReader dr         = command.ExecuteReader();
                    int           PracticeId = 0;
                    while (dr.Read())
                    {
                        PracticeId = int.Parse(dr["Practice_id"].ToString());
                        Practice l = new Practice();
                        l.PracticeId = PracticeId;
                        l.GetPractice(userId);
                        PracticesInObjective.Add(l);
                    }

                    connection.Close();
                }
            }
        }
Esempio n. 2
0
        public Practice PreviousPractice()
        {
            Practice previousId = null;

            foreach (Practice l in PracticesInObjective)//assume sortted by order
            {
                if (l.PracticeId == PracticeId)
                {
                    return(previousId);
                }
                else
                {
                    previousId = l;
                }
            }
            return(null); //First Practice?
        }