Beispiel #1
0
 // Update student
 public async Task <Student> UpdateStudentAsync(Student student)
 {
     try
     {
         var studentExist = dbContext.Students.FirstOrDefault(p => p.StudentID == student.StudentID);
         if (studentExist != null)
         {
             dbContext.Update(student);
             await dbContext.SaveChangesAsync();
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(student);
 }
Beispiel #2
0
 // Update SchoolClass
 public async Task <SchoolClass> UpdateSchoolClassAsync(SchoolClass schoolClass)
 {
     try
     {
         var schoolClassExist = dbContext.SchoolClasses.FirstOrDefault(p => p.SchoolClassID == schoolClass.SchoolClassID);
         if (schoolClassExist != null)
         {
             dbContext.Update(schoolClass);
             await dbContext.SaveChangesAsync();
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(schoolClass);
 }
 // Update student
 public async Task <Teacher> UpdateTeacherAsync(Teacher teacher)
 {
     try
     {
         var teacherExist = dbContext.Teachers.FirstOrDefault(p => p.TeacherID == teacher.TeacherID);
         if (teacherExist != null)
         {
             dbContext.Update(teacher);
             await dbContext.SaveChangesAsync();
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(teacher);
 }