static void Main(string[] args) { using (StudentClient client = new StudentClient("BasicHttpBinding_IStudent")) { //Firkantede klammer efter Student klasse er fordi GetallStudent har Ilist<Student> som datatype. Student[] allstudents = client.GetAllStudents(); foreach (var st in allstudents) { Console.WriteLine(st.StudentName); } Console.WriteLine("Studerendes navn med id 4:"); Student stu = client.GetStudentById(4); Console.WriteLine(stu.StudentName); Console.WriteLine("Studerendes id med navn test"); Student stu2 = client.GetStudentByName("Hansi"); Console.WriteLine(stu2.StudentId); client.AddStudent(8, "Kamsolle"); client.DeleteStudentById(7); client.UpdateStudent("2", "JO"); } Console.ReadLine(); }
protected void Button1_Click(object sender, EventArgs e) { Student obj = new Student() { Id = Convert.ToInt32(txt_ID.Text), StudentName = txt_Name.Text, StudentClass = txt_Class.Text, StudentCourse = txt_course.Text, }; client.AddStudent(obj); Response.Write("<script>alert('Added Successfully !! ')</script>"); }
static void Main(string[] args) { using (StudentClient sc = new StudentClient()) { sc.AddStudent(new Student { name = "Ivan", add = new Address { city = "Rivne", street = "Soborna" } }); sc.BeginGetStudents(GetCallback, sc); // sc.GetStudentsAsync(); Console.WriteLine("Main works...."); Console.ReadLine(); } }