public ActionResult Edit([Bind(Include = "MaTG,Hinh,TenTG,TieuSu,GioiTinh")] TacGia tacGia) { if (ModelState.IsValid) { db.Entry(tacGia).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tacGia)); }
public ActionResult Edit([Bind(Include = "OrderID,OrderName,OrderDate,CustomerName,CustomerPhone,CustomerEmail,CustomerAddress")] Order order) { if (ModelState.IsValid) { db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(order)); }
public ActionResult Edit([Bind(Include = "MaPhanHoi,HoTen,Email,DiaChi,SDT,NoiDung")] PhanHoi phanHoi) { if (ModelState.IsValid) { db.Entry(phanHoi).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(phanHoi)); }
public ActionResult SaveBook(int?id, string name, int price, int authorId, int categoryId, string description, string review, HttpPostedFileBase image) { var user = Session["Account"] as Account; if (user.IsAdmin == false || user == null) { return(RedirectToAction("UnAuthorized", "Authentication")); } string img = null; if (image != null) { img = Path.GetFileName(image.FileName); string path = Path.Combine(Server.MapPath("~/Images/Books/"), img); image.SaveAs(path); } if (id != null) { var bookEdit = db.Book.SingleOrDefault(b => b.Id == id); bookEdit.Name = name; bookEdit.Price = price; bookEdit.Description = description; bookEdit.Review = review; bookEdit.AuthorId = authorId; bookEdit.CategoryId = categoryId; if (img != null) { bookEdit.Image = img; } db.Entry(bookEdit); db.SaveChanges(); return(RedirectToAction("Manage")); } var book = new Book { Name = name, Price = price, Description = description, Review = review, AuthorId = authorId, CategoryId = categoryId, Image = img }; db.Book.Add(book); db.SaveChanges(); return(RedirectToAction("Manage")); }
public ActionResult Edit([Bind(Include = "id,OrderID,Price,Quantity,Status")] OrderDetail orderDetail) { if (ModelState.IsValid) { db.Entry(orderDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OrderID = new SelectList(db.Order, "OrderID", "OrderName", orderDetail.OrderID); return(View(orderDetail)); }
public ActionResult Edit([Bind(Include = "id,gia,tensp,hinh,mota,ttc_kichthuoc,ttc_ngayxuatban,ttc_loaibia,ttc_sotrang,ttc_nhaxuatban,motasanpham,MaDM,MaNXB")] Sach sach) { if (ModelState.IsValid) { db.Entry(sach).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaDM = new SelectList(db.DanhMuc, "MaDM", "TenDanhMuc", sach.MaDM); ViewBag.MaNXB = new SelectList(db.NhaXuatBan, "MaNXB", "TenNXB", sach.MaNXB); return(View(sach)); }
public ActionResult Edit(string address, string phone, string email) { var info = db.Info.SingleOrDefault(inf => inf.Id == 1); info.Address = address; info.Phone = phone; info.Email = email; db.Entry(info); db.SaveChanges(); return(Redirect("Index")); }
public bool Add_NV(nhanvien nv) { try { CSDL db = new CSDL(); db.Entry(nv).State = System.Data.Entity.EntityState.Added; db.SaveChanges(); return(true); } catch (Exception e) { return(false); } }