Пример #1
0
        public ActionResult SaveUpdateHotel(Lodge EditHotelDetails)
        {
            PlanItDBEntities ORM            = new PlanItDBEntities();
            Lodge            OldHotelRecord = ORM.Lodges.Find(EditHotelDetails.Lodging);


            if (OldHotelRecord != null && ModelState.IsValid)
            {
                OldHotelRecord.Lodging        = EditHotelDetails.Lodging;
                OldHotelRecord.Price          = EditHotelDetails.Price;
                OldHotelRecord.NumberOfNights = EditHotelDetails.NumberOfNights;
                OldHotelRecord.Address        = EditHotelDetails.Address;
                OldHotelRecord.City           = EditHotelDetails.City;
                OldHotelRecord.State          = EditHotelDetails.State;
                OldHotelRecord.PostalCode     = EditHotelDetails.PostalCode;
                OldHotelRecord.PhoneNumber    = EditHotelDetails.PhoneNumber;
                OldHotelRecord.URL            = EditHotelDetails.URL;
                OldHotelRecord.TripID         = EditHotelDetails.TripID;

                ORM.Entry(OldHotelRecord).State = System.Data.Entity.EntityState.Modified;
                ORM.SaveChanges();

                TempData["currentTrip"] = ORM.Trips.Find(EditHotelDetails.TripID);
                TempData["currentTrip"] = TempData["currentTrip"];

                return(RedirectToAction("../Home/TripSummary"));
            }
            else
            {
                TempData["currentTrip"] = TempData["currentTrip"];

                ViewBag.Message = "Hotel Not Found";
                return(View("Error"));
            }
        }
        private void SumCalculate()
        {
            string select   = comboTypeBox.SelectedItem.ToString().ToLower().Split()[0];
            string fullname = nameInputBox.Text.ToString().ToLower();
            double discount = 1;
            double cost     = 0;

            foreach (Client client in cashbox.GetClients())
            {
                if (String.Equals(client.fullName.ToLower(), fullname))
                {
                    discount = client.discount;
                }
            }

            if (String.Equals(select, "партерр"))
            {
                cost = discount * Parterre.GetCost();
            }
            else if (String.Equals(select, "балкон"))
            {
                cost = discount * Balcony.GetCost();
            }
            else if (String.Equals(select, "ложа"))
            {
                cost = discount * Lodge.GetCost();
            }
            sumTicketBox.Text = "Стоимость билета: " + cost + " руб.";
        }
Пример #3
0
        public ActionResult SaveHotelOption()
        {
            PlanItDBEntities ORM = new PlanItDBEntities();

            Trip    currentTrip     = (Trip)TempData["currentTrip"];
            string  thisHotel       = (string)TempData["HotelSelection"];
            string  NumberOfNights  = (string)TempData["NumberOfNights"];
            string  hotelPricePoint = (string)TempData["hotelPricePoint"];
            JObject currentHotel    = JObject.Parse(thisHotel);
            string  hotelName       = currentHotel["name"].ToString();
            Lodge   newHotel        = new Lodge();

            Lodge Found = ORM.Lodges.Find(hotelName);

            if (Found != null)
            {
                TempData["hotelPricePoint"] = null;
                TempData["HotelSelection"]  = null;
                TempData["NumberOfNights"]  = null;

                ViewBag.DuplicateHotel = "The hotel you chose is already on your list";

                TempData["currentTrip"] = TempData["currentTrip"];
                return(View("Error"));
            }
            else
            {
                newHotel.Lodging        = (string)currentHotel["name"];
                newHotel.Price          = int.Parse(hotelPricePoint);
                newHotel.NumberOfNights = int.Parse(NumberOfNights);
                newHotel.Address        = (string)currentHotel["location"]["address1"];
                newHotel.City           = (string)currentHotel["location"]["city"];
                newHotel.State          = (string)currentHotel["location"]["state"];
                newHotel.PostalCode     = (string)currentHotel["location"]["zip_code"];
                newHotel.PhoneNumber    = (string)currentHotel["display_phone"];
                newHotel.URL            = (string)currentHotel["url"];
                newHotel.TripID         = currentTrip.TripID;

                ORM.Lodges.Add(newHotel);
                ORM.SaveChanges();

                Trip editedTrip = ORM.Trips.Find(newHotel.TripID);

                TempData["currentTrip"] = editedTrip;
                TempData["currentTrip"] = TempData["currentTrip"];

                return(RedirectToAction("../Home/TripSummary"));
            }
        }
Пример #4
0
        public ActionResult EditHotelDetails(string Lodging)
        {
            PlanItDBEntities ORM         = new PlanItDBEntities();
            Lodge            Found       = ORM.Lodges.Find(Lodging);
            Trip             currentTrip = (Trip)TempData["currentTrip"];

            ViewBag.DayDiff = HomeController.NumOfDays(currentTrip);

            TempData["currentTrip"] = TempData["currentTrip"];
            if (Found != null)
            {
                return(View("EditHotelDetails", Found));
            }
            else
            {
                ViewBag.ErrorMessage = "Hotel Not Found";
                return(View("Error"));
            }
        }
Пример #5
0
        /// <summary>
        /// Definition of method designed to add new record to Keepers table
        /// </summary>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="contactNumber"></param>
        /// <param name="lodgeId"></param>
        public bool AddKeeper(string firstName, string lastName, string contactNumber, int lodgeId)
        {
            Lodge lodge = DBContext.Lodges.SingleOrDefault(l => l.Id == lodgeId);

            if (lodge == null)
            {
                return(false);
            }

            Keeper keeperNew = new Keeper()
            {
                FirstName     = firstName,
                LastName      = lastName,
                ContactNumber = contactNumber,
                LodgeId       = lodge.Id
            };

            DBContext.Keepers.Add(keeperNew);
            return(DBContext.SaveChanges() > 0);
        }
Пример #6
0
        public ActionResult DeleteHotel(string Lodging)
        {
            PlanItDBEntities ORM         = new PlanItDBEntities();
            Lodge            Found       = ORM.Lodges.Find(Lodging);
            Trip             currentTrip = ORM.Trips.Find(Found.TripID);

            if (Found != null)
            {
                ORM.Lodges.Remove(Found);
                ORM.SaveChanges();

                TempData["currentTrip"] = currentTrip;
                TempData["currentTrip"] = TempData["currentTrip"];

                return(RedirectToAction("../Home/TripSummary"));
            }
            else
            {
                TempData["currentTrip"] = TempData["currentTrip"];

                ViewBag.Message = "Hotel Not Found";
                return(View("Error"));
            }
        }