Пример #1
0
        public BookViewModel GetBookView(Guid bookID)
        {
            BookViewModel bookViewModel = new BookViewModel();
            Book          book          = booksLibraryDataContext.Books.FirstOrDefault(x => x.IDBook == bookID);

            if (book != null)
            {
                bookViewModel.IDBook              = book.IDBook;
                bookViewModel.Name                = book.Name;
                bookViewModel.Author              = book.Author;
                bookViewModel.Publisher           = book.Publisher;
                bookViewModel.NumberOfCopies      = book.NumberOfCopies;
                bookViewModel.IDBooksCategory     = book.IDBooksCategory;
                bookViewModel.IDLocationInLibrary = book.IDLocationInLibrary;
                bookViewModel.imageUrl            = book.imageUrl;
                IQueryable <BooksCategory> booksCategories = booksLibraryDataContext.BooksCategories.Where(x => x.IDBooksCategory == bookID);
                foreach (BooksCategory dbBooksCategory in booksCategories)
                {
                    Models.BooksCategoryModel booksCategoryModel = new Models.BooksCategoryModel();
                    booksCategoryModel.IDBooksCategory = dbBooksCategory.IDBooksCategory;
                    booksCategoryModel.Genre           = dbBooksCategory.Genre;

                    bookViewModel.BooksCategories.Add(booksCategoryModel);
                }
            }
            return(bookViewModel);
        }
Пример #2
0
 public ActionResult Edit(Guid id, FormCollection collection)
 {
     try
     {
         // TODO: Add update logic here
         Models.BooksCategoryModel booksCategoryModel = new Models.BooksCategoryModel();
         UpdateModel(booksCategoryModel);
         booksCategoryRepository.UpdateBookCategory(booksCategoryModel);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View("EditBooksCategory"));
     }
 }
Пример #3
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here
                Models.BooksCategoryModel booksCategoryModel = new Models.BooksCategoryModel();
                UpdateModel(booksCategoryModel);
                booksCategoryRepository.InsertBookCategory(booksCategoryModel);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("CreateBooksCategory"));
            }
        }
Пример #4
0
 // GET: BooksCategory/Delete/5
 public ActionResult Delete(Guid id)
 {
     Models.BooksCategoryModel booksCategoryModel = booksCategoryRepository.GetBookCategoryByID(id);
     return(View("DeleteBooksCategory", booksCategoryModel));
 }