public ActionResult EditTouristSpots(TOURIST_SPOTS touristSpots, HttpPostedFileBase fileUpload) { if (ModelState.IsValid) { try { TOURIST_SPOTS model = db.TOURIST_SPOTS.Single(x => x.ID_TOURISTSPOT == touristSpots.ID_TOURISTSPOT); model.NAME_TOURISTSPOT = touristSpots.NAME_TOURISTSPOT; model.ID_TOURISTSPOT = touristSpots.ID_TOURISTSPOT; model.IMAGE_TOURIST_SPOTS = touristSpots.IMAGE_TOURIST_SPOTS; model.INTRODUCE_TOURIST_SPOTS = touristSpots.INTRODUCE_TOURIST_SPOTS; model.QUALITY_TOURISTSPOT = touristSpots.QUALITY_TOURISTSPOT; model.TEL_TOURISTSPOT = touristSpots.TEL_TOURISTSPOT; model.DES_TOURIST_SPOTS = touristSpots.DES_TOURIST_SPOTS; model.ID_CITY = touristSpots.ID_CITY; //model = hotel; db.SaveChanges(); } catch (Exception ex) { return(RedirectToAction("Error", new { msg = ex.Message })); } } return(RedirectToAction("Tourist_Spots")); }
public ActionResult DeleteTouristSpots(int id) { //Lay ra doi tuong san pham can xoa theo ma TOURIST_SPOTS touristSpots = db.TOURIST_SPOTS.SingleOrDefault(n => n.ID_TOURISTSPOT == id); if (touristSpots == null) { Response.StatusCode = 404; return(null); } return(View()); }
public ActionResult EditTouristSpots(int id) { //Lay doi tuong sanpham theo ma TOURIST_SPOTS touristSpots = db.TOURIST_SPOTS.SingleOrDefault(n => n.ID_TOURISTSPOT == id); if (touristSpots == null) { Response.StatusCode = 404; return(null); } //Dua du lieu vao dropdownlist //Lay ds tu table phan khuc, sap xep tang dan theo ten phan khuc, chon lay gia tri MaDM, hien thi TenDM //ViewBag.MaDM = new SelectList(db.DANHMUCs.ToList().OrderBy(n => n.TenDM), "MaDM", "TenDM", sanpham.MaDM); return(View(touristSpots)); }
public ActionResult CreateTouristSpots(TOURIST_SPOTS touristSpots, HttpPostedFileBase fileUpload) { if (db.TOURIST_SPOTS.Any(x => x.ID_TOURISTSPOT == touristSpots.ID_TOURISTSPOT)) { touristSpots.ID_TOURISTSPOT = db.TOURIST_SPOTS.Max(x => x.ID_TOURISTSPOT) + 1; } if (fileUpload == null) { return(View()); } if (ModelState.IsValid) { var fileName = Path.GetFileName(fileUpload.FileName); //Luu duong dan cua file var path = Path.Combine(Server.MapPath("~/Images"), fileName); //Kiem tra hinh anh ton tai chua if (System.IO.File.Exists(path)) { ViewBag.Message = "Image was existed ! Please choose another image."; return(View()); } else { //Luu hinh anh vao duong dan fileUpload.SaveAs(path); touristSpots.IMAGE_TOURIST_SPOTS = path; } try { db.TOURIST_SPOTS.Add(touristSpots); db.SaveChanges(); } catch (Exception ex) { return(RedirectToAction("Error", new { msg = ex.Message })); } } else { return(View()); } return(RedirectToAction("Tourist_Spots")); }
public ActionResult DeleteTouristSpots(int id, int?aaa) { try { TOURIST_SPOTS touristSpots = db.TOURIST_SPOTS.SingleOrDefault(n => n.ID_TOURISTSPOT == id); if (touristSpots == null) { Response.StatusCode = 404; return(null); } db.TOURIST_SPOTS.Remove(touristSpots); db.SaveChanges(); return(RedirectToAction("Tourist_Spots")); } catch (Exception ex) { return(RedirectToAction("Error", new { msg = ex.Message })); } return(View()); }
public ActionResult CreateTouristSpots() { TOURIST_SPOTS model = new TOURIST_SPOTS(); return(View(model)); }