private void btnSave_Click(object sender, EventArgs e) { BookMasterBL objbook = new BookMasterBL(); try { BookMaster b = new BookMaster(); //b--->>bookmaster b.BookId = Convert.ToInt32(txtBookId.Text); b.BookName = txtBookName.Text; b.BookStatus = Convert.ToString(cmbStatus.SelectedItem); objbook.SaveBookMasterdata(b); MessageBox.Show("Record is Saved..."); } catch (Exception ex) { MessageBox.Show("Record is Not Saved..."); objbook.InserToErrorLog("Book", ex.Message.ToString(), "btnSave_Click"); } finally { } }
public int DeleteBookMasterdataFromDB(BookMaster objBook) { int n = 0; //spDeleteBookMasterDetails try { SqlCommand cmd = new SqlCommand("spDeleteBookMasterDetails", con.ActiveCon()); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Book_Id", objBook.BookId); n = cmd.ExecuteNonQuery(); n = n > 0 ? 1 : 0; } catch (Exception ex) { InsertToErrorLog("BookDA", ex.Message.ToString(), "DeleteBookMasterdataFromDB"); } finally { con.CloseCon(); } return(n); }
public int SaveBookMasterdataToDB(BookMaster objBook) { int n = 0; try { SqlCommand cmd = new SqlCommand("spInsBookMasterDetails", con.ActiveCon()); //Constant file cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Book_Id", objBook.BookId); cmd.Parameters.AddWithValue("@Book_Name", objBook.BookName); cmd.Parameters.AddWithValue("@Book_Status", objBook.BookStatus); n = cmd.ExecuteNonQuery(); n = n > 0 ? 1 : 0; } catch (Exception ex) { InsertToErrorLog("BookDA", ex.Message.ToString(), "SaveBookMasterdataToDB"); } finally { con.CloseCon(); } return(n); }
public async Task <BookMaster> AddBookMaster(BookMaster newBook) { var addBookResult = await appDbContext.BookMaster.AddAsync(newBook); await appDbContext.SaveChangesAsync(); return(addBookResult.Entity); }
//public class CarViewModel //{ // public string Car { get; set; } // public List<SelectListItem> Cars { get; } = GetSelectListItems(); //} public ActionResult About() { //ViewBag.CarsList = GetSelectListItems();//the first Demo var model = new BookMaster(); //the third Demo model.Publishers = new SelectList(GetPublishers(), "PublisherId", "PublisherName", 2); //the second Demo model.PublisherId = "2"; ViewBag.Message = "Your application description page."; return(View(model)); }
public IActionResult DeleteBook(DeleteBookViewModel bookModel) { BookMaster bookToDelete = _bookMasterRepository.GetBook(bookModel.BookId); int deleteSuccessFlag = _bookMasterRepository.DeleteBook(bookToDelete); if (deleteSuccessFlag > 0) { return(RedirectToAction("Index", "Book")); } ModelState.AddModelError("", "Operation unsuccessful. Book id is not correct."); return(View(bookModel)); }
public ActionResult Create([Bind(Include = "BookId,BookName,BookPrice,AuthorID")] BookMaster bookMaster) { if (ModelState.IsValid) { _IBookRepository.InsertBook(bookMaster); _IBookRepository.Save(); return(RedirectToAction("Index")); } ViewBag.AuthID = new SelectList(_IAuthorRepository.GetAuthors(), "AuthorID", "AuthorName", bookMaster.AuthorID); return(View(bookMaster)); }
public IActionResult UpdateBook(UpdateBookViewModel book) { BookMaster bookToUpdate = _bookMasterRepository.GetBook(book.BookMasterId); int updateSuccessFlag = _bookMasterRepository.DeleteBook(bookToUpdate); if (updateSuccessFlag > 0) { return(RedirectToAction("Index", "Book")); } ModelState.AddModelError("", "Operation not successfull"); return(RedirectToAction("Update", "Book")); }
// GET: BookMasters/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BookMaster bookMaster = _IBookRepository.GetBookByID(id); if (bookMaster == null) { return(HttpNotFound()); } return(View(bookMaster)); }
public ActionResult EditPopup(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BookMaster bookMaster = _IBookRepository.GetBookByID(id); if (bookMaster == null) { return(HttpNotFound()); } ViewBag.AuthID = new SelectList(_IAuthorRepository.GetAuthors(), "AuthorID", "AuthorName", bookMaster.AuthorID); return(PartialView("_BookEdit", bookMaster)); }
public int UpdateBookMasterData(BookMaster b) { int n = 0; IBookMasterDA objBook = new BookMasterDA(); try { n = Convert.ToInt32(objBook.UpdateBookMasterdataToDB(b)); } catch (Exception ex) { objBook.InsertToErrorLog("BookBL", ex.Message.ToString(), "UpdateBookMasterData"); } return(n); }
public async Task <ActionResult <BookMaster> > AddBookMaster(BookMaster newBook) { try { if (newBook == null) { return(BadRequest()); } var CreatedBook = await bookMasterRepository.AddBookMaster(newBook); return(CreatedAtAction(nameof(GetBookMaster), new { id = CreatedBook.BookMasterID }, CreatedBook)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Error to add Book Details.")); } }
private void btnDelete_Click(object sender, EventArgs e) { BookMasterBL objbook = new BookMasterBL(); try { BookMaster b = new BookMaster(); b.BookId = Convert.ToInt32(txtBookId.Text); objbook.DeleteBookMasterData(b); MessageBox.Show("Record is Deleted..."); } catch (Exception ex) { MessageBox.Show("Record is Not Deleted..."); objbook.InserToErrorLog("Book", ex.Message.ToString(), "btnDelete_Click"); } }
public IActionResult Update(UpdateBookViewModel book) { BookMaster bookToUpdate = _bookMasterRepository.GetBook(book.BookMasterId); if (bookToUpdate != null) { var updateBookViewModel = new UpdateBookViewModel { InfoFetched = true, Title = bookToUpdate.Title, Author = bookToUpdate.Author, BookMasterId = bookToUpdate.BookMasterId, ShortDescription = bookToUpdate.ShortDescription, LongDescription = bookToUpdate.LongDescription }; ModelState.AddModelError("", "Sorry!Feature not implemented yet."); return(View(updateBookViewModel)); } ModelState.AddModelError("", "Operation unsuccessful. Book id is not correct."); return(View(book)); }
public IActionResult AddBook(AddBookViewModel book) { if (ModelState.IsValid) { int userId = Int32.Parse(HttpContext.Session.GetString("UserId")); BookMaster bookToAdd = new BookMaster { Title = book.Title, Author = book.Author, ShortDescription = book.ShortDescription, LongDescription = book.LongDescription, UserId = userId }; if (_bookMasterRepository.AddBook(bookToAdd) > 0) { return(RedirectToAction("Index", "Book")); } ModelState.AddModelError("", "Operation unsuccessful. Book already present in database."); return(View(book)); } return(View(book)); }
public void DeleteBook(int bookID) { BookMaster book = _context.BookMasters.Find(bookID); _context.BookMasters.Remove(book); }
public async Task <BookMaster> AddBookMaster(BookMaster newBook) { return(await httpClient.PostJsonAsync <BookMaster>("api/BookMaster", newBook)); }
public void InsertBook(BookMaster book) { _context.BookMasters.Add(book); }
public void UpdateBook(BookMaster book) { _context.Entry(book).State = EntityState.Modified; }
public ActionResult Edit(BookMaster bookmaster) { if (ModelState.IsValid) { db.Entry(bookmaster).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(bookmaster); }