public string Add(int IdStudent, string NameStudent) { SchoolEntity school = new SchoolEntity(); Students student = new Students(); student.StudentId = IdStudent; student.StudentName = NameStudent; //version 3.5 is school.AddToStudents and 4.6 version is school.Students.Add school.AddToStudents(student); school.SaveChanges(); return("Ok"); }
public string ReadAll() { SchoolEntity school = new SchoolEntity(); List <StudentS> studentS = new List <StudentS>(); StudentS stu = null; foreach (var s in school.Students) { stu = new StudentS { IdStudent = s.StudentId, NameStudent = s.StudentName }; studentS.Add(stu); } string jsonStudents = JsonConvert.SerializeObject(studentS); return(jsonStudents); }