Ejemplo n.º 1
0
        public int AddDetail(Issue obj)
        {
            db.Issues.Add(obj);
            db.SaveChanges();

            return(obj.IssueNo);
        }
Ejemplo n.º 2
0
        public int AddDetail(Book obj)
        {
            db.Books.Add(obj);
            db.SaveChanges();

            return(obj.BookId);
        }
Ejemplo n.º 3
0
 public virtual bool SaveData(T model)
 {
     using (var _LMContext = new LMContext())
     {
         _LMContext.Set <T>().Add(model);
         return(_LMContext.SaveChanges() > 0);
     }
 }
Ejemplo n.º 4
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);
     }
 }
Ejemplo n.º 5
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);
     }
 }
Ejemplo n.º 8
0
 public int SavePicture(Picture picture)
 {
     _LMContext.Pictures.Add(picture);
     _LMContext.SaveChanges();
     return(picture.ID);
 }