public void DeleteBookCategory(Guid ID) { Models.DBObjects.BooksCategory booksCategoryToDelete = booksLibraryDataContext.BooksCategories.FirstOrDefault(x => x.IDBooksCategory == ID); if (booksCategoryToDelete != null) { booksLibraryDataContext.BooksCategories.DeleteOnSubmit(booksCategoryToDelete); booksLibraryDataContext.SubmitChanges(); } }
public void UpdateBookCategory(BooksCategoryModel booksCategoryModel) { Models.DBObjects.BooksCategory existingBooksCategory = booksLibraryDataContext.BooksCategories.FirstOrDefault(x => x.IDBooksCategory == booksCategoryModel.IDBooksCategory); if (existingBooksCategory != null) { existingBooksCategory.IDBooksCategory = booksCategoryModel.IDBooksCategory; existingBooksCategory.Genre = booksCategoryModel.Genre; existingBooksCategory.ChildAppropriate = booksCategoryModel.ChildAppropriate; booksLibraryDataContext.SubmitChanges(); } }
private Models.DBObjects.BooksCategory MapModelToDbObject(BooksCategoryModel booksCategoryModel) { Models.DBObjects.BooksCategory dbbookCategoryModel = new Models.DBObjects.BooksCategory(); if (booksCategoryModel != null) { dbbookCategoryModel.IDBooksCategory = booksCategoryModel.IDBooksCategory; dbbookCategoryModel.Genre = booksCategoryModel.Genre; dbbookCategoryModel.ChildAppropriate = booksCategoryModel.ChildAppropriate; return(dbbookCategoryModel); } return(null); }
private BooksCategoryModel MapDbObjectToModel(Models.DBObjects.BooksCategory dbbookCategory) { BooksCategoryModel booksCategoryModel = new BooksCategoryModel(); if (dbbookCategory != null) { booksCategoryModel.IDBooksCategory = dbbookCategory.IDBooksCategory; booksCategoryModel.Genre = dbbookCategory.Genre; booksCategoryModel.ChildAppropriate = dbbookCategory.ChildAppropriate; return(booksCategoryModel); } return(null); }