/// <summary> /// Created By : Ashwajit Bansod /// Created For : To save and update book data by using book id /// </summary> /// <param name="obj"></param> /// <returns></returns> public bool SaveBookData(BookListModel obj) { bool isSave = false; try { if (obj.BookId == 0) { var tableData = new Tbl_BookStore(); tableData.BookName = obj.BookName; tableData.BookPic = obj.BookPic; tableData.BookPrice = obj.BookPrice; tableData.BookISBN = obj.BookISBN; tableData.BookPublication = obj.BookPublication; tableData.BookDate = obj.BookDate; tableData.AuthorName = obj.AuthorName; tableData.BookDescription = obj.BookDescription; tableData.IsDelete = false; _db.Tbl_BookStore.Add(tableData); _db.SaveChanges(); isSave = true; } else { var getData = _db.Tbl_BookStore.Where(x => x.BookId == obj.BookId).FirstOrDefault(); getData.BookName = obj.BookName; getData.BookPic = obj.BookPic; getData.BookPrice = obj.BookPrice; getData.BookISBN = obj.BookISBN; getData.BookPublication = obj.BookPublication; getData.BookDate = obj.BookDate; getData.AuthorName = obj.AuthorName; getData.BookDescription = obj.BookDescription; getData.IsDelete = false; _db.Entry(getData).State = EntityState.Modified; _db.SaveChanges(); isSave = true; } } catch (Exception ex) { isSave = false; throw; } return(isSave); }
public ActionResult Edit([Bind(Include = "BCategoryID,BCategoryName")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Edit([Bind(Include = "BId,BName,BDesc,BCategoryID")] Book book) { if (ModelState.IsValid) { db.Entry(book).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(book)); }
public async Task <ActionResult> Edit([Bind(Include = "id,name,quantityHours,semestr")] Subjects subjects) { if (ModelState.IsValid) { db.Entry(subjects).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(subjects)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Coach")] Teams teams) { if (ModelState.IsValid) { db.Entry(teams).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(teams)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Author,Price")] Books books) { if (ModelState.IsValid) { db.Entry(books).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(books)); }
public async Task <ActionResult> Edit([Bind(Include = "id,firstName,secondName,middleName,groupName")] Students students) { if (ModelState.IsValid) { db.Entry(students).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(students)); }
public async Task <ActionResult> Edit([Bind(Include = "id,Person,book_id")] Purchase purchase) { if (ModelState.IsValid) { db.Entry(purchase).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.book_id = new SelectList(db.Books, "Id", "Name", purchase.book_id); return(View(purchase)); }
public async Task <ActionResult> Edit([Bind(Include = "id,Name,Age,Position,TeamId")] Players players) { if (ModelState.IsValid) { db.Entry(players).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.TeamId = new SelectList(db.Teams, "Id", "Name", players.TeamId); return(View(players)); }
public ActionResult DeleteBook(int id) { Book target = null; using (BookstoreEntities dbContext = new BookstoreEntities()) { target = dbContext.Book.SingleOrDefault(t => t.Id == id); target.status = false; dbContext.Entry(target).State = System.Data.Entity.EntityState.Modified; dbContext.SaveChanges(); } return(RedirectToAction("BookList", new { pageNumber = 1 })); }
public async Task <ActionResult> Edit([Bind(Include = "id,id_student,id_subject")] StudentsSubject studentsSubject) { if (ModelState.IsValid) { db.Entry(studentsSubject).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.id_student = new SelectList(db.Students, "id", "firstName", studentsSubject.id_student); ViewBag.id_subject = new SelectList(db.Subjects, "id", "name", studentsSubject.id_subject); return(View(studentsSubject)); }
public ActionResult Edit(string id, BookDetail book) { try { // TODO: Add update logic here dbmodel.Entry(book).State = EntityState.Modified; dbmodel.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult EditBook(Book book) { using (BookstoreEntities dbContext = new BookstoreEntities()) { if (this.Request.Files != null && this.Request.Files.Count > 0 && this.Request.Files[0].ContentLength > 0) { string fileName = Path.GetFileName(this.Request.Files[0].FileName); string filePathOfWebsite = "~/Images/Covers/" + fileName; book.CoverImagePath = filePathOfWebsite; this.Request.Files[0].SaveAs(this.Server.MapPath(filePathOfWebsite)); } dbContext.Entry(book).State = System.Data.Entity.EntityState.Modified; dbContext.SaveChanges(); } return(RedirectToAction("BookList", new { pageNumber = 1 })); }