Ejemplo n.º 1
0
        public ActionResult CreateBookingExtraParticipant(BookingExtraParticipant bookingExtraParticipant, string submitBookingExtraPart)
        {
            PortugalVillasContext db = new PortugalVillasContext();

            if (ModelState.IsValid)
            {
                GeneralStaticHelperMethods.IsPersonAdultChildOrInfant(bookingExtraParticipant);
                //need to assign the booking ID
                BookingExtraSelection currentSelection = (BookingExtraSelection)Session["CurrentBookingExtraDataGathering"];
                bookingExtraParticipant.BookingExtraSelectionID = currentSelection.BookingExtraSelectionID;

                db.BookingExtraParticipants.Add(bookingExtraParticipant);
                db.SaveChanges();

                //check they're under 18 or whatever then make them an infant, or child if they're the corresponsing age
                //is infant
                //is child

                if (submitBookingExtraPart.Equals("Add this participant and add another"))
                {
                    return(RedirectToAction("CreateBookingExtraParticipant"));
                }
            }

            return(RedirectToAction("DetailGatheringEventChain"));
        }
        public static bool IsPersonAdultChildOrInfant(BookingExtraParticipant theParticipant)
        {
            DateTime dob = (DateTime)theParticipant.BookingExtraParticipantDOB;

            //under 2
            if ((DateTime.Now.Subtract(dob).Days < 730))
            {
                theParticipant.BookingExtraParticipantInfant = true;
                theParticipant.BookingExtraParticipantChild  = false;

                return(true);
            }


            else if ((DateTime.Now.Subtract(dob).Days < 6575))
            {
                theParticipant.BookingExtraParticipantInfant = false;
                theParticipant.BookingExtraParticipantChild  = true;
                return(true);
            }

            theParticipant.BookingExtraParticipantInfant = false;
            theParticipant.BookingExtraParticipantChild  = false;

            return(false);
        }
        public ActionResult DeleteConfirmed(long id)
        {
            BookingExtraParticipant bookingextraparticipant = db.BookingExtraParticipants.Find(id);
            var besid = bookingextraparticipant.BookingExtraSelectionID;

            db.BookingExtraParticipants.Remove(bookingextraparticipant);
            db.SaveChanges();
            return(RedirectToAction("Index", new { BookingExtraSelectionId = besid }));
        }
        public ActionResult Details(long id = 0)
        {
            BookingExtraParticipant bookingextraparticipant = db.BookingExtraParticipants.Find(id);

            if (bookingextraparticipant == null)
            {
                return(HttpNotFound());
            }
            return(View(bookingextraparticipant));
        }
        //
        // GET: /BookingExtraParticipant/Edit/5

        public ActionResult Edit(long id = 0)
        {
            BookingExtraParticipant bookingextraparticipant = db.BookingExtraParticipants.Find(id);

            if (bookingextraparticipant == null)
            {
                return(HttpNotFound());
            }

            ViewBag.ID = (long)Session["recentBES"];
            return(View(bookingextraparticipant));
        }
        public ActionResult Create(BookingExtraParticipant bookingextraparticipant)
        {
            bookingextraparticipant.BookingExtraParticipantWhenCreated = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.BookingExtraParticipants.Add(bookingextraparticipant);
                db.SaveChanges();
                ViewBag.ID = (long)Session["recentBES"];
                return(RedirectToAction("Index", new { BookingExtraSelectionId = bookingextraparticipant.BookingExtraSelectionID }));
            }


            return(View(bookingextraparticipant));
        }
        //
        // GET: /BookingExtraParticipant/Delete/5

        public ActionResult Delete(long id = 0)
        {
            BookingExtraParticipant bookingextraparticipant = db.BookingExtraParticipants.Find(id);

            if (bookingextraparticipant == null)
            {
                return(HttpNotFound());
            }
            var besid = bookingextraparticipant.BookingExtraSelectionID;

            db.BookingExtraParticipants.Remove(bookingextraparticipant);
            db.SaveChanges();
            return(RedirectToAction("Index", new { BookingExtraSelectionId = besid }));
        }
        public ActionResult Edit(BookingExtraParticipant bookingextraparticipant)
        {
            var old =
                db.BookingExtraParticipants.Where(
                    c => c.BookingExtraSelectionID == bookingextraparticipant.BookingExtraSelectionID).FirstOrDefault();

            bookingextraparticipant.BookingExtraParticipantWhenCreated = old.BookingExtraParticipantWhenCreated;

            if (ModelState.IsValid)
            {
                using (var _db = new PortugalVillasContext())
                {
                    _db.BookingExtraParticipants.Attach(bookingextraparticipant);
                    _db.Entry(bookingextraparticipant).State = EntityState.Modified;
                    _db.SaveChanges();
                    return(RedirectToAction("Index",
                                            new { BookingExtraSelectionId = bookingextraparticipant.BookingExtraSelectionID }));
                }
            }
            ViewBag.ID = (long)Session["recentBES"];
            return(View(bookingextraparticipant));
        }