public ActionResult DeleteResort(int id) { //Lay ra doi tuong san pham can xoa theo ma RESORT resort = db.RESORTs.SingleOrDefault(n => n.ID_RESORT == id); if (resort == null) { Response.StatusCode = 404; return(null); } return(View(resort)); }
public ActionResult EditResort(int id) { //Lay doi tuong sanpham theo ma RESORT resort = db.RESORTs.SingleOrDefault(n => n.ID_RESORT == id); if (resort == 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(resort)); }
public ActionResult CreateResort(RESORT resort, HttpPostedFileBase fileUpload) { if (db.RESORTs.Any(x => x.ID_RESORT == resort.ID_RESORT)) { resort.ID_RESORT = db.RESORTs.Max(x => x.ID_RESORT) + 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); resort.IMAGE_RESORT = path; } try { db.RESORTs.Add(resort); db.SaveChanges(); } catch (Exception ex) { return(RedirectToAction("Error", new { msg = ex.Message })); } } else { return(View()); } return(RedirectToAction("Resort")); }
public ActionResult EditResort(RESORT resort, HttpPostedFileBase fileUpload) { if (ModelState.IsValid) { try { RESORT model = db.RESORTs.Single(x => x.ID_RESORT == resort.ID_RESORT); model.NAME_RESORT = resort.NAME_RESORT; //ve them cac field con lai //model = hotel; db.SaveChanges(); } catch (Exception ex) { return(RedirectToAction("Error", new { msg = ex.Message })); } } return(RedirectToAction("Resort")); }
public ActionResult DeleteResort(int id, int?aaa) { try { RESORT resort = db.RESORTs.SingleOrDefault(n => n.ID_RESORT == id); if (resort == null) { Response.StatusCode = 404; return(null); } db.RESORTs.Remove(resort); db.SaveChanges(); return(RedirectToAction("Resort")); } catch (Exception ex) { return(RedirectToAction("Error", new { msg = ex.Message })); } //return View(); }
public ActionResult CreateResort() { RESORT model = new RESORT(); return(View(model)); }