public IActionResult Edit(int id) { if (ModelState.IsValid) { //ViewBag.TheLoais = GetTheLoais(); var emp = bookRespository.Get(id); var students = new EditBooksViewsModel { Mota = emp.Mota, SoLuong = emp.SoLuong, TenSach = emp.TenSach, Nsx = emp.Nsx, TenTacGia = emp.TenTacGia, TheLoaiId = emp.TheLoaiId }; ViewBag.TheLoais = GetTheLoais(); return(View(students)); } return(View()); }
public IActionResult Edit(EditBooksViewsModel model) { var emp = bookRespository.Get(model.Id); var stu = new Book() { SoLuong = model.SoLuong, TenSach = model.TenSach, Id = model.Id, Mota = model.Mota, Nsx = model.Nsx, TenTacGia = model.TenTacGia, TheLoaiId = model.TheLoaiId }; var lophoc = bookRespository.Edit(stu); if (lophoc != null) { return(RedirectToAction("Index", new { id = lophoc.Id })); } ViewBag.TheLoais = GetTheLoais(); return(View(model)); }