예제 #1
0
 public virtual bool UpdateData(T model)
 {
     using (var _LMContext = new LMContext())
     {
         _LMContext.Entry(model).State = System.Data.Entity.EntityState.Modified;
         return(_LMContext.SaveChanges() > 0);
     }
 }
예제 #2
0
 public virtual bool DeleteData(int id)
 {
     using (var _LMContext = new LMContext())
     {
         var designation = _LMContext.Set <T>().Find(id);
         _LMContext.Entry(designation).State = System.Data.Entity.EntityState.Modified;
         _LMContext.Set <T>().Remove(designation);
         return(_LMContext.SaveChanges() > 0);
     }
 }
 public override bool UpdateData(Student model)
 {
     using (var _LMContext = new LMContext())
     {
         var existingStudent = _LMContext.Students.Find(model.ID);
         _LMContext.StudentPictures.RemoveRange(existingStudent.StudentPictures);
         _LMContext.Entry(existingStudent).CurrentValues.SetValues(model);
         _LMContext.StudentPictures.AddRange(model.StudentPictures);
         return(_LMContext.SaveChanges() > 0);
     }
 }
 public override bool UpdateData(Book model)
 {
     using (var _LMContext = new LMContext())
     {
         var existingBook = _LMContext.Books.Find(model.ID);
         _LMContext.BookPictures.RemoveRange(existingBook.BookPictures);
         _LMContext.Entry(existingBook).CurrentValues.SetValues(model);
         _LMContext.BookPictures.AddRange(model.BookPictures);
         return(_LMContext.SaveChanges() > 0);
     }
 }