// Delete student public void DeleteStudent(Student student) { if (student != null) { Students.Remove(student.Id); } // Step 2: Save students after updated JsonFileReaderWriter.WriteToJsonSerialization(Students, filePath); }
// Add New Resource public void AddNewStudent(Student newStudent) { // Call this method for auto increment manually ( when we use SQL server then we disable this on that time) var student = AutoIncrementId(newStudent); // step 1: Add new Student in the existing list of Getallstudents Students.Add(student.Id, student); // Step 3: Save file with added students into File JsonFileReaderWriter.WriteToJsonSerialization(Students, filePath); }
// Update student public void UpdateStudent(Student student) { // Step 1 : Update specific student if (student != null) { Students[student.Id].Id = student.Id; Students[student.Id].Name = student.Name; Students[student.Id].Image = student.Image; Students[student.Id].Email = student.Email; Students[student.Id].Profession = student.Profession; } // Step 2: Save students after updated JsonFileReaderWriter.WriteToJsonSerialization(Students, filePath); }