public ActionResult Edit(Table_Promote table_Promote, HttpPostedFileBase file) { try { var recordToUpdate = db.Table_Promote.AsNoTracking().Single(x => x.Promote_ID == table_Promote.Promote_ID); if (file != null && file.ContentLength > 0) { var myUniqueFileName = DateTime.Now.Ticks + ".jpg"; string physicalPath = Server.MapPath("~/img/" + myUniqueFileName); file.SaveAs(physicalPath); table_Promote.Promote_Pic = myUniqueFileName; } else { table_Promote.Promote_Pic = recordToUpdate.Promote_Pic; } } catch (Exception) { ViewBag.Message = "อัพเดทข้อมูลไม่สำเร็จ กรุณาตรวจสอบข้อมูลและลองใหม่อีกครั้ง"; } db.Entry(table_Promote).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Typeuser_ID,TypeuserName")] Table_Typeuser table_Typeuser) { if (ModelState.IsValid) { db.Entry(table_Typeuser).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(table_Typeuser)); }
public ActionResult Edit([Bind(Include = "Owner_ID,Firstname,Lastname,Address,Telephone")] Table_Owner table_Owner) { if (ModelState.IsValid) { db.Entry(table_Owner).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(table_Owner)); }
public ActionResult Edit([Bind(Include = "Username,Password,Typeuser_ID")] AdminLogin adminLogin) { if (ModelState.IsValid) { db.Entry(adminLogin).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Typeuser_ID = new SelectList(db.Table_Typeuser, "Typeuser_ID", "TypeuserName", adminLogin.Typeuser_ID); return(View(adminLogin)); }
public ActionResult Edit(Table_Visit table_Visit) { if (ModelState.IsValid) { db.Entry(table_Visit).State = EntityState.Modified; table_Visit.VisitDate = DateTime.UtcNow; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Pet_ID = new SelectList(db.Table_Pet, "Pet_ID", "Pet_Name", table_Visit.Pet_ID); return(View(table_Visit)); }
public ActionResult Edit(Table_Pet table_Pet) { if (ModelState.IsValid) { db.Entry(table_Pet).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Owner_ID = new SelectList(db.Table_Owner, "Owner_ID", "Firstname", table_Pet.Owner_ID); ViewBag.Type_ID = new SelectList(db.Table_TypePet, "Type_ID", "TypeName", table_Pet.Type_ID); return(View(table_Pet)); }