public ActionResult Create([Bind(Include = "BookId,CategoryId,Title,AuthorId,PublisherId,Description,Price,ISBN,PublicationDate,Image")] Book book) { if (ModelState.IsValid) { string imgUrl = HttpContext.Server.MapPath("~/Content/Image/BookId") + GetBookIdCount() + ".jpg"; System.IO.File.Create(imgUrl, 1).Close(); //string src = @"C:\Users\abhishekshi\Pictures\320x150.gif"; System.IO.File.Copy(book.Image, imgUrl, true); book.Image = "/Content/Image/BookId" + GetBookIdCount() + ".jpg"; if (book.BookId != 0) { db.Entry(book).State = EntityState.Modified; ViewBag.AuthorId = new SelectList(db.Author, "AuthorId", "AuthorName", book.AuthorId); ViewBag.CategoryId = new SelectList(db.Category, "CategoryId", "CategoryName", book.CategoryId); ViewBag.PublisherId = new SelectList(db.Publisher, "PublisherId", "PublisherName", book.PublisherId); } else { ViewBag.AuthorId = new SelectList(db.Author, "AuthorId", "AuthorName", book.AuthorId); ViewBag.CategoryId = new SelectList(db.Category, "CategoryId", "CategoryName", book.CategoryId); ViewBag.PublisherId = new SelectList(db.Publisher, "PublisherId", "PublisherName", book.PublisherId); db.Book.Add(book); } } db.SaveChanges(); return(RedirectToAction("Index")); }
public bool Upsert(T entity) { if (entity.Id > 0) { // for updateing _dbContext.Entry(entity).State = EntityState.Modified; return(_dbContext.SaveChanges() > 0); } // for inserting _dbContext.Set <T>().Add(entity); return(_dbContext.SaveChanges() > 0); }
public ActionResult Edit([Bind(Include = "PublisherId,PublisherName,DateOfBirth,State,City,Phone")] Publisher publisher) { if (ModelState.IsValid) { db.Entry(publisher).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(publisher)); }
public ActionResult Edit([Bind(Include = "BookId,Bookname,Authorname,BookType,price")] Book book) { if (ModelState.IsValid) { db.Entry(book).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(book)); }
public ActionResult Edit([Bind(Include = "UserInfoId,Username,emailId,password,MobileNo,city,role")] UserInfo userInfo) { if (ModelState.IsValid) { db.Entry(userInfo).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userInfo)); }
public ActionResult Edit([Bind(Include = "id,BookId,Description,FirstName,LastName")] BookReview bookreview) { if (ModelState.IsValid) { db.Entry(bookreview).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bookreview)); }
public ActionResult Edit([Bind(Include = "CategoryId,CategoryName,Description")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Edit([Bind(Include = "id,BookId,Description,UserName,isValid")] BookReview bookreview) { if (ModelState.IsValid) { db.Entry(bookreview).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BookId = new SelectList(db.Book, "BookId", "Title", bookreview.BookId); return(View(bookreview)); }
public ActionResult Edit([Bind(Include = "BookId,CategoryId,AuthorId,Title,Price,AlbumArtUrl")] Books albums) { if (ModelState.IsValid) { db.Entry(albums).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AuthorId = new SelectList(db.Authors, "AuthorId", "Name", albums.AuthorId); ViewBag.CategoryId = new SelectList(db.Categorys, "CategoryId", "Name", albums.CategoryId); return(View(albums)); }
public ActionResult Edit([Bind(Include = "BookId,CategroyId,AuthorId,Title,Price,Details,ImageUrl")] Book book) { if (ModelState.IsValid) { db.Entry(book).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AuthorId = new SelectList(db.Authors, "AuthorId", "Name", book.AuthorId); ViewBag.CategroyId = new SelectList(db.Categorys, "CategoryId", "Name", book.CategroyId); return(View(book)); }
public void Update(T entity) { _dbContext.Entry(entity).State = EntityState.Modified; _dbContext.SaveChanges(); }