public List<User> GetUsers() { try { using (var context = new LibrarySystemEntities()) { return context.Users.ToList(); } } catch (Exception) { throw; } }
public List<Publisher> GetPublisheres() { try { using (var context = new LibrarySystemEntities()) { context.Configuration.ProxyCreationEnabled = false; return context.Publisher.ToList(); } } catch (Exception) { throw; } }
public List<BorrowInfo> GetBorrowInfoes() { try { using (var context = new LibrarySystemEntities()) { context.Configuration.ProxyCreationEnabled = false; return context.BorrowInfoes.ToList(); } } catch (Exception) { throw; } }
public Book GetBookById(int _id) { try { using (var contex = new LibrarySystemEntities()) { contex.Configuration.ProxyCreationEnabled = false; contex.Configuration.LazyLoadingEnabled = false; Book book = contex.Books.FirstOrDefault(c => c.BookId == _id); return book; } } catch (Exception) { throw; } }
public Publisher GetPublisherById(int _id) { try { using (var contex = new LibrarySystemEntities()) { contex.Configuration.ProxyCreationEnabled = false; contex.Configuration.LazyLoadingEnabled = false; Publisher publisher = contex.Publisher.FirstOrDefault(c => c.PublisherId == _id); return publisher; } } catch (Exception) { throw; } }
public User GetUserById(int _id) { try { using (var contex = new LibrarySystemEntities()) { contex.Configuration.LazyLoadingEnabled = false; User user = contex.Users.FirstOrDefault(c => c.UserId == _id); return user; } } catch (Exception) { throw; } }
public Publisher UpdatePublisher(Publisher _publisher) { try { using (var context = new LibrarySystemEntities()) { Publisher oldpublisher = context.Publisher.FirstOrDefault(c => c.PublisherId == _publisher.PublisherId); if (oldpublisher != null) { oldpublisher.PublisherName = _publisher.PublisherName; oldpublisher.PublisherId = _publisher.PublisherId; oldpublisher.IsActive = _publisher.IsActive; context.SaveChanges(); return oldpublisher; } return null; } } catch (Exception) { throw; } }
public BorrowInfo UpdateBorrowInfo(BorrowInfo _borrow) { try { using (var context = new LibrarySystemEntities()) { BorrowInfo oldborrow = context.BorrowInfoes.FirstOrDefault(c => c.BorrowId == _borrow.BorrowId); if (oldborrow != null) { oldborrow.BorrowDate = _borrow.BorrowDate; oldborrow.ReturnDate = _borrow.ReturnDate; oldborrow.ReaderId = _borrow.ReaderId; oldborrow.IsActive = _borrow.IsActive; context.SaveChanges(); return oldborrow; } return null; } } catch (Exception) { throw; } }
public Publisher AddPublisher(Publisher _publisher) { try { using (var context = new LibrarySystemEntities()) { context.Configuration.ProxyCreationEnabled = false; context.Publisher.Add(_publisher); context.SaveChanges(); return _publisher; } } catch (Exception) { throw; } }
public User DeleteUser(int _id) { try { using (var context = new LibrarySystemEntities()) { User user = context.Users.FirstOrDefault(cstm => cstm.UserId == _id); context.Users.Remove(user); int i = context.SaveChanges(); return user; } } catch (Exception) { throw; } }
public BorrowInfo DeleteBorrow(int _id) { try { using (var context = new LibrarySystemEntities()) { BorrowInfo borrow = context.BorrowInfoes.FirstOrDefault(cstm => cstm.BorrowId == _id); context.BorrowInfoes.Remove(borrow); int i = context.SaveChanges(); //return i > 0; return borrow; } } catch (Exception) { throw; } }
public User UpdateUser(User _user) { try { using (var context = new LibrarySystemEntities()) { User olduser = context.Users.FirstOrDefault(c => c.UserId == _user.UserId); if (olduser != null) { olduser.FirstName = _user.FirstName; olduser.LastName = _user.LastName; olduser.Password = _user.Password; context.SaveChanges(); return olduser; } return null; } } catch (Exception) { throw; } }
public Reader UpdateReader(Reader _reader) { try { using (var context = new LibrarySystemEntities()) { Reader oldreader = context.Readers.FirstOrDefault(c => c.ReaderId == _reader.ReaderId); if (oldreader != null) { oldreader.FirstName = _reader.FirstName; oldreader.LastName = _reader.LastName; oldreader.Phone = _reader.Phone; oldreader.Mail = _reader.Mail; context.SaveChanges(); return oldreader; } return null; } } catch (Exception) { throw; } }
public Publisher DeletePublisher(int _id) { try { using (var context = new LibrarySystemEntities()) { Publisher publisher = context.Publisher.FirstOrDefault(cstm => cstm.PublisherId == _id); context.Publisher.Remove(publisher); int i = context.SaveChanges(); //return i > 0; return publisher; } } catch (Exception) { throw; } }
public Book DeleteBook(int _bookId) { try { using (var context = new LibrarySystemEntities()) { context.Configuration.ProxyCreationEnabled = false; Book book = context.Books.FirstOrDefault(cstm => cstm.BookId == _bookId); context.Books.Remove(book); int i = context.SaveChanges(); return book; } } catch (Exception) { throw; } }
public Book UpdateBook(Book _book) { try { using (var context = new LibrarySystemEntities()) { context.Configuration.ProxyCreationEnabled = false; Book oldbook = context.Books.FirstOrDefault(c => c.BookId == _book.BookId); if (oldbook != null) { oldbook.BookName = _book.BookName; oldbook.BookPages = _book.BookPages; oldbook.BookPrice = _book.BookPrice; oldbook.CategoryId = _book.CategoryId; context.SaveChanges(); return oldbook; } return null; } } catch (Exception) { throw; } }
public Book AddBook(Book _book) { try { using (var context = new LibrarySystemEntities()) { context.Configuration.ProxyCreationEnabled = false; context.Books.Add(_book); context.SaveChanges(); return _book; } } catch (Exception) { throw; } }
public User AddUser(User _user) { try { using (var context = new LibrarySystemEntities()) { context.Users.Add(_user); context.SaveChanges(); return _user; } } catch (Exception) { throw; } }
public Reader AddReader(Reader _reader) { try { using (var context = new LibrarySystemEntities()) { context.Readers.Add(_reader); context.SaveChanges(); return _reader; } } catch (Exception) { throw; } }