public static bool ChinhSuaTour(ThaoTacTourViewModel tourViewModel) { QlTourDuLichEntities entity = new QlTourDuLichEntities(); try { TOUR tour = entity.TOURs.Where(t => t.MaTour == tourViewModel.Tour.MaTour).FirstOrDefault(); tour.MaTour = tourViewModel.Tour.MaTour; tour.TenTour = tourViewModel.Tour.TenTour; //tour.AnhDaiDien = tourViewModel.AnhDiaDiem; tour.GiaNguoiLon = tourViewModel.Tour.GiaNguoiLon; tour.GiaTreEm = tourViewModel.Tour.GiaTreEm; tour.MaHanhTrinh = entity.HANHTRINHs.FirstOrDefault(t => (t.NoiDen == tourViewModel.Tour.MaDiaDiemDen) && t.NoiDi == tourViewModel.Tour.MaDiaDiemDi).MaHanhTrinh; tour.MaHDV = tourViewModel.Tour.MaHDV; tour.MaKS = tourViewModel.KhachSan; tour.MaLoaiTour = tourViewModel.Tour.LoaiTour; tour.NgayKetThuc = tourViewModel.Tour.NgayKT; tour.NgayKhoiHanh = tourViewModel.Tour.NgayKH; entity.SaveChanges(); return(true); } catch (Exception) { entity.Dispose(); return(false); } }
public static bool ThemTour(ThaoTacTourViewModel tourDTO) { QlTourDuLichEntities entity = new QlTourDuLichEntities(); try { TOUR tour = new TOUR() { MaTour = new Random().Next(0, 10000).ToString(), //AnhDaiDien = tourDTO.AnhDiaDiem, GiaNguoiLon = tourDTO.Tour.GiaNguoiLon, GiaTreEm = tourDTO.Tour.GiaTreEm, MaHanhTrinh = entity.HANHTRINHs.FirstOrDefault(t => (t.NoiDi == tourDTO.Tour.MaDiaDiemDi && t.NoiDen == tourDTO.Tour.MaDiaDiemDen)).MaHanhTrinh, MaHDV = tourDTO.Tour.MaHDV, MaKS = tourDTO.KhachSan, MaLoaiTour = tourDTO.Tour.LoaiTour, NgayKetThuc = tourDTO.Tour.NgayKT, NgayKhoiHanh = tourDTO.Tour.NgayKH, }; entity.TOURs.Add(tour); entity.SaveChanges(); return(true); } catch (Exception) { entity.Dispose(); } return(false); }
// // GET: /QuanTriVien/Tour/Create public ActionResult ThemTour() { ThaoTacTourViewModel model = new ThaoTacTourViewModel(); ViewBag.MaLoaiTour = model.LoaiTours; ViewBag.MaKS = model.KhachSans; ViewBag.MaDiaDiemDi = model.DiemDis; ViewBag.MaDiaDiemDen = model.DiemDens; ViewBag.HuongDanVien = model.HuongDanViens; return(View(model)); }
// // GET: /QuanTriVien/Default1/Edit/5 public ActionResult SuaTour(string id = null) { ThaoTacTourViewModel model = new ThaoTacTourViewModel(id); if (model == null) { return(HttpNotFound()); } ViewBag.MaLoaiTour = model.LoaiTours; ViewBag.MaKS = model.KhachSans; ViewBag.MaDiaDiemDi = model.DiemDis; ViewBag.MaDiaDiemDen = model.DiemDens; ViewBag.HuongDanVien = model.HuongDanViens; return(View(model)); }
public ActionResult ThemTour(ThaoTacTourViewModel model) { if (!(ModelState.IsValid && TourQueries.ThemTour(model))) { TempData["KetQua"] = "thêm tour du lịch này thất bại"; ThaoTacTourViewModel model1 = new ThaoTacTourViewModel(); ViewBag.MaLoaiTour = model1.LoaiTours; ViewBag.MaKS = model1.KhachSans; ViewBag.MaDiaDiemDi = model1.DiemDis; ViewBag.MaDiaDiemDen = model1.DiemDens; ViewBag.HuongDanVien = model1.HuongDanViens; return(View(model1)); } TempData["KetQua"] = "thêm tour du lịch này thành công"; return(RedirectToAction("Index")); }
public ActionResult SuaTour(ThaoTacTourViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction("SuaTour", new { @id = model.Tour.MaTour })); } if (TourQueries.ChinhSuaTour(model)) { TempData["KetQua"] = "Sửa Thành công"; return(RedirectToAction("Index")); } else { TempData["KetQua"] = "sửa Thất bại"; return(RedirectToAction("SuaTour", new { @id = model.Tour.MaTour })); } }