Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(long id)
        {
            BookingExternal bookingexternal = db.BookingExternals.Find(id);

            db.BookingExternals.Remove(bookingexternal);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        //
        // GET: /BookingExternal/Details/5

        public ActionResult Details(long id = 0)
        {
            BookingExternal bookingexternal = db.BookingExternals.Find(id);

            if (bookingexternal == null)
            {
                return(HttpNotFound());
            }
            return(View(bookingexternal));
        }
Ejemplo n.º 3
0
        //this function creates a BookingDate for every booking date and adds it to the list of booking dates
        public void GetAllBookingDatesAndAddToThisCalendar()
        {
            PortugalVillasContext _db             = new PortugalVillasContext();
            List <Booking>        theBookingDates = Booking.GetAllBookingsForAProperty(this.PropertyID);
            var externalDates = BookingExternal.GetExternalBookingsAsBookings(this.PropertyID);

            //add external dates
            theBookingDates.AddRange(externalDates);

            //add our system dates
            if (theBookingDates.Any())
            {
                //create and add each booked date to the 'bookingDates' list.
                foreach (Booking aBooking in theBookingDates)
                {
                    try
                    {
                        if (aBooking.Confirmed == true && aBooking.Cancelled == false)
                        {
                            //foreach booking
                            DateTime    tempDate        = aBooking.StartDate.Value;
                            BookingDate tempBookingDate = new BookingDate();

                            switch (aBooking.Confirmed)
                            {
                            case true:
                                tempBookingDate.bookingDateType = BookingDate.BookingDateType.Confirmed;
                                break;

                                /* case false:
                                 * tempBookingDate.bookingDateType = BookingDate.BookingDateType.Provisional;
                                 * break;*/
                            }

                            //THIS STOPS A DAY BEFORE THE ACTUAL BOOKING
                            //add a new booking date to the list - stop at last date as we want that to be available for another booking
                            while (tempDate < aBooking.EndDate)
                            {
                                bookingDates.Add(
                                    new BookingDate()
                                {
                                    bookingDate     = tempDate,
                                    bookingDateType = tempBookingDate.bookingDateType
                                });
                                tempDate = tempDate.AddDays(1);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        //ignore it, process the next one
                    }
                }
            }
        }
        // GET api/<controller>/5
        public IEnumerable <BookingExternalSyncRequest> Get()
        {
            var bookingsthisSystem = Booking.ToBookingExternalSyncRequests(db.Bookings.Where(x => x.Confirmed == true && x.Cancelled == false && x.StartDate > (DateTime)DateTime.Now).ToList()) as List <BookingExternalSyncRequest>;


            bookingsthisSystem.AddRange(
                BookingExternal.ToBookingExternalSyncRequests(db.BookingExternals.Where(x => (DateTime)x.StartDate > (DateTime)DateTime.Now).ToList())
                );

            return(bookingsthisSystem);
        }
Ejemplo n.º 5
0
 public ActionResult Edit(BookingExternal bookingexternal)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bookingexternal).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PropertyID = new SelectList(db.Properties, "PropertyID", "LegacyReference", bookingexternal.PropertyID);
     return(View(bookingexternal));
 }
Ejemplo n.º 6
0
        //
        // GET: /BookingExternal/Edit/5

        public ActionResult Edit(long id = 0)
        {
            BookingExternal bookingexternal = db.BookingExternals.Find(id);

            if (bookingexternal == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PropertyID = new SelectList(db.Properties, "PropertyID", "LegacyReference", bookingexternal.PropertyID);
            return(View(bookingexternal));
        }
Ejemplo n.º 7
0
        public ActionResult Create(BookingExternal bookingexternal)
        {
            if (ModelState.IsValid)
            {
                db.BookingExternals.Add(bookingexternal);
                db.SaveChanges();
                return(RedirectToAction("Create"));
            }

            ViewBag.PropertyID = new SelectList(db.Properties, "PropertyID", "LegacyReference", bookingexternal.PropertyID);
            return(View(bookingexternal));
        }