コード例 #1
0
        public IActionResult AddHotels(TourHotel model)
        {
            if (HttpContext.Session.GetString("ID") == null)
            {
                return(RedirectToAction("Login", "Admin"));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    int    hotelID = Convert.ToInt32(model.HotelID);
                    string tourID  = model.TourID.ToString();
                    if (tourRepository.checkHotelID(tourID, hotelID))
                    {
                        tourRepository.AddHotel(model);
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "This Hotel already exists.");
                        //ViewBag.Error = "This Hotel already exists.";

                        //If the system encounters an error, immediately go to the Addhotel page.
                        //return Redirect("https://localhost:44361/Tour/AddHotel/"+tourID);
                        TempData["Error"] = "This Hotel already exists.";
                        return(RedirectToAction("AddHotel", "Tour", new { Id = tourID }));
                    }
                }
                //If the system encounters an error, immediately go to the Addhotel page.
                return(Redirect("https://localhost:44361/Tour/AddHotel/" + model.TourID));
            }
        }
コード例 #2
0
        public ActionResult Index()
        {
            //Display Active Home
            ViewBag.isActive = UtilContants.HOME_NAV;

            TourModel model = new TourModel();
            var       tour  = model.listTourHot();
            var       hotel = model.listHotel();
            var       listComboBoxToPlace   = model.listComboBoxToPlace();
            var       listComboBoxFromPlace = model.listComboBoxFromPlace();
            TourHotel listContainer         = new TourHotel();

            listContainer.Tour  = tour;
            listContainer.Hotel = hotel;
            listContainer.listComboBoxFromPlace = listComboBoxFromPlace;
            listContainer.listComboBoxToPlace   = listComboBoxToPlace;


            return(View(listContainer));
        }
コード例 #3
0
 public void AddHotel(TourHotel _TourHotel)
 {
     db.tbl_TourHotel.Add(_TourHotel);
     db.SaveChanges();
 }