Esempio n. 1
0
        public List <parentClass> read(Guid id)
        {
            if (id == null)
            {
                return(new List <parentClass>());
            }

            SqlConnection con = new SqlConnection(data);
            SqlCommand    cmd = new SqlCommand("SELECT * FROM courseParent WHERE courseId = @courseId", con);

            cmd.Parameters.AddWithValue("@courseId", id);

            List <parentClass> response = new List <parentClass>();
            SqlDataReader      Dr;

            con.Open();
            Dr = cmd.ExecuteReader();
            while (Dr.Read())
            {
                parentClass parent = new parentClass();
                parent.parentId = new Guid(Dr["parentId"].ToString());
                parent.name     = Dr["name"].ToString();
                parent.creator  = new Guid(Dr["creator"].ToString());
                parent.courseId = new Guid(Dr["courseId"].ToString());

                child.child read = new child.child();
                parent.child = read.read(parent.parentId);

                response.Add(parent);
            }
            con.Close();

            return(response);
        }
Esempio n. 2
0
        public List <parentClass> readString(string courseId)
        {
            if (courseId == null || courseId.Length <= 0)
            {
                return(new List <parentClass>());
            }
            List <parentClass> response = new List <parentClass>();
            Guid id = new Guid(courseId);

            try
            {
                response = read(id);
            }
            catch (Exception ex)
            {
                parentClass add = new parentClass();
                add.name = ex.ToString();
                response.Add(add);
                return(response);
            }

            return(response);
        }