Esempio n. 1
0
 // Save and Update ****
 public SchoolClass SaveSchoolClass(SchoolClass schoolClass)
 {
     if (schoolClass.Id == 0)
     {
         _context.SchoolClass.Add(schoolClass);
         _context.SaveChanges();
         return(schoolClass);
     }
     else
     {
         SchoolClass sc = _context.SchoolClass.Find(schoolClass.Id);
         if (sc != null)
         {
             sc.ClassName = schoolClass.ClassName;
             _context.SchoolClass.Update(sc);
             _context.SaveChanges();
             return(sc);
         }
     }
     return(null);
 }