public List <BookCategoryDTO> BookCategry() { using (IDbSvc dbSvc = new DbSvc(_configSvc)) { try { dbSvc.OpenConnection(); MySqlCommand command = new MySqlCommand(); command.CommandText = "select BookCategoryId,BookCategory from bookcategory where Active=1"; command.Connection = dbSvc.GetConnection() as MySqlConnection; _dtData = new DataTable(); MySqlDataAdapter msDa = new MySqlDataAdapter(command); msDa.Fill(_dtData); List <BookCategoryDTO> lstBookCategory = new List <BookCategoryDTO>(); if (_dtData != null && _dtData.Rows.Count > 0) { BookCategoryDTO bookcategoryDTO = null; foreach (DataRow dr in _dtData.Rows) { bookcategoryDTO = new BookCategoryDTO(); bookcategoryDTO.BookCategoryId = (int)dr["BookCategoryId"]; bookcategoryDTO.BookCategory = dr["BookCategory"].ToString(); lstBookCategory.Add(bookcategoryDTO); } } return(lstBookCategory); } catch (Exception exp) { throw exp; } } }
// GET: Book/Create public ActionResult Create() { var categories = _categoryService.GetAll(); var authors = _authorService.GetAll(); var data = new BookCategoryDTO() { Category = categories, Author = authors }; return(View(data)); }
public List <BookCategoryDTO> GetListBookCategoryStatusTrue() { List <BookCategoryDTO> bookCategoryDTOs = new List <BookCategoryDTO>(); string query = string.Format("SELECT * FROM dbo.BookCategory WHERE Status = 1"); DataTable dataTable = DataProvider.Instance.ExcuteQuery(query); foreach (DataRow item in dataTable.Rows) { BookCategoryDTO librarianDTO = new BookCategoryDTO(item); bookCategoryDTOs.Add(librarianDTO); } return(bookCategoryDTOs); }
// GET: Book/Edit/5 public ActionResult Edit(int id) { var book = _service.GetById(id); var categories = _categoryService.GetAll(); var authors = _authorService.GetAll(); var data = new BookCategoryDTO() { Book = book, Category = categories, Author = authors }; return(View(data)); }