Esempio n. 1
0
        // Convert dates in number of days counting from today
        private void CreateViewBagsForDates(long selectedID = newReservationMode)
        {
            session  _session  = sessionService.GetSession(this.HttpContext);
            ipmevent _IPMEvent = ipmevents.GetById(_session.idIPMEvent);

            // Read and convert the dates to a value than can be used by jQuery Datepicker
            DateTime start        = _IPMEvent.startDate.Value;
            DateTime end          = _IPMEvent.endDate.Value;
            DateTime now          = DateTime.Now;
            DateTime checkInDate  = DateTime.MinValue;
            DateTime checkOutDate = DateTime.MinValue;

            // Parameters for Edit Reservation, NOT used for New Reservation
            if (selectedID != newReservationMode)
            {
                selecteditem _selecteditem = selecteditems.GetById(selectedID);
                checkInDate  = _selecteditem.checkInDate;
                checkOutDate = _selecteditem.checkOutDate;
            }

            if (checkInDate == DateTime.MinValue)
            {
                if (_session.checkInDate != null)
                {
                    checkInDate = _session.checkInDate.Value;
                }
                ;
            }
            ;
            if (checkOutDate == DateTime.MinValue)
            {
                if (_session.checkOutDate != null)
                {
                    checkOutDate = _session.checkOutDate.Value;
                }
                ;
            }
            ;

            if (!(checkInDate >= start && checkInDate <= end))
            {
                checkInDate = start;
            }
            ;
            if (!(checkOutDate >= checkInDate && checkOutDate <= end))
            {
                checkOutDate = end;
            }
            ;

            int min      = (int)(start - now).TotalDays + 1;
            int max      = (int)(end - now).TotalDays + 1;
            int checkIn  = (int)(checkInDate - now).TotalDays - 7;
            int checkOut = (int)(checkOutDate - now).TotalDays + 1;

            ViewBag.minDate      = min;
            ViewBag.maxDate      = max;
            ViewBag.checkInDate  = checkIn;
            ViewBag.checkOutDate = checkOut;
        }
Esempio n. 2
0
        public ActionResult SelectSite(long idRVSite, DateTime checkInDate, DateTime checkOutDate)
        {
            var _session = sessionService.GetSession(this.HttpContext, true, false);

            // Check if site is really available
            bool isRVSiteAvailable = rvsites_available.GetAll().
                                     Where(s => s.idIPMEvent == _session.idIPMEvent && s.id == idRVSite).
                                     ToList().Count() > 0;

            if (isRVSiteAvailable)
            {
                // Check if site is already in the list (it was previously cancelled)
                // If it is, remove it
                var old_selecteditems = selecteditems.GetAll().Where(osi => osi.idRVSite == idRVSite).ToList();
                foreach (var old_selecteditem in old_selecteditems)
                {
                    //selecteditems.Delete(old_selecteditem.ID);
                    //selecteditems.Commit();
                }
                ;

                // Add selected item to the database
                var _selecteditem = new selecteditem();
                var type_rates    = sites_description_rate.GetAll().
                                    Where(s => s.id == idRVSite).FirstOrDefault();

                _selecteditem.checkInDate   = checkInDate;
                _selecteditem.checkOutDate  = checkOutDate;
                _selecteditem.weeklyRate    = type_rates.weeklyRate.Value;
                _selecteditem.dailyRate     = type_rates.dailyRate.Value;
                _selecteditem.idRVSite      = idRVSite;
                _selecteditem.idSession     = _session.ID;
                _selecteditem.idIPMEvent    = _session.idIPMEvent;
                _selecteditem.idStaff       = _session.idStaff;
                _selecteditem.idCustomer    = _session.idCustomer;
                _selecteditem.site          = type_rates.RVSite;
                _selecteditem.siteType      = type_rates.description;
                _selecteditem.isSiteChecked = true;
                CalcSiteTotal calcResults = new CalcSiteTotal(
                    checkInDate,
                    checkOutDate,
                    type_rates.weeklyRate.Value,
                    type_rates.dailyRate.Value,
                    true);
                _selecteditem.duration   = calcResults.duration;
                _selecteditem.weeks      = calcResults.weeks;
                _selecteditem.days       = calcResults.days;
                _selecteditem.amount     = calcResults.amount;
                _selecteditem.total      = calcResults.total;
                _selecteditem.createDate = DateTime.Now;
                _selecteditem.lastUpdate = DateTime.Now;
                _selecteditem.timeStamp  = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");

                selecteditems.Insert(_selecteditem);
                selecteditems.Commit();
            }

            return(Json(idRVSite));
        }
Esempio n. 3
0
        public ActionResult SelectSite(long idRVSite, DateTime checkInDate, DateTime checkOutDate)
        {
            var _session = sessionService.GetSession(this.HttpContext);

            // Add selected item to the database
            var _selecteditem = new selecteditem();
            var type_rates    = sites_description_rate.GetAll().
                                Where(s => s.id == idRVSite).FirstOrDefault();

            _selecteditem.checkInDate   = checkInDate;
            _selecteditem.checkOutDate  = checkOutDate;
            _selecteditem.weeklyRate    = type_rates.weeklyRate.Value;
            _selecteditem.dailyRate     = type_rates.dailyRate.Value;
            _selecteditem.idRVSite      = idRVSite;
            _selecteditem.idSession     = _session.ID;
            _selecteditem.idIPMEvent    = _session.idIPMEvent;
            _selecteditem.idStaff       = _session.idStaff;
            _selecteditem.idCustomer    = _session.idCustomer;
            _selecteditem.site          = type_rates.RVSite;
            _selecteditem.siteType      = type_rates.description;
            _selecteditem.isSiteChecked = true;
            CalcSiteTotal calcResults = new CalcSiteTotal(
                checkInDate,
                checkOutDate,
                type_rates.weeklyRate.Value,
                type_rates.dailyRate.Value,
                true);

            _selecteditem.duration   = calcResults.duration;
            _selecteditem.weeks      = calcResults.weeks;
            _selecteditem.days       = calcResults.days;
            _selecteditem.amount     = calcResults.amount;
            _selecteditem.total      = calcResults.total;
            _selecteditem.createDate = DateTime.Now;
            _selecteditem.lastUpdate = DateTime.Now;

            selecteditems.Insert(_selecteditem);
            selecteditems.Commit();

            return(Json(idRVSite));
        }
Esempio n. 4
0
        // Partial View for CRUD of Reserved Site
        public ActionResult CRUDReservedItem(long selectedID = newReservationMode)
        {
            ViewBag.UserID = sessionService.GetSessionUserID(this.HttpContext, true, false);
            CreateViewBagsForDates(selectedID);

            // Parameters for Edit Reservation, NOT used for New Reservation
            if (selectedID != newReservationMode)
            {
                selecteditem _selecteditem = selecteditems.GetById(selectedID);
                ViewBag.SelectedID = selectedID;
                ViewBag.SiteID     = _selecteditem.idRVSite;
                placeinmap _placeinmap = placesinmap.GetById(_selecteditem.idRVSite);
                ViewBag.SiteName = _placeinmap.site;
            }
            else
            {
                ViewBag.SiteID = newReservationMode;
            }

            return(PartialView());
        }
Esempio n. 5
0
        public ActionResult EditReservation()
        {
            long sessionUserID = sessionService.GetSessionUserID(this.HttpContext, true, false);

            ViewBag.UserID = sessionUserID;

            long sessionID         = sessionService.GetSessionID(this.HttpContext, false, false);
            long sessionCustomerID = sessionService.GetSessionCustomerID(sessionID);

            ViewBag.Customer = sessionService.GetSessionCustomerNamePhone(sessionID);

            long sessionIPMEventID = sessionService.GetSessionIPMEventID(sessionID);

            var _reserveditems = reservationitems.GetAll();

            if (sessionCustomerID != IDnotFound)
            {
                _reserveditems = reservationitems.GetAll().
                                 Where(q => q.idCustomer == sessionCustomerID && q.isCancelled != true).
                                 OrderByDescending(o => o.idRVSite);
            }

            // Discard reserved items from other years
            long IPMEventID = sessionService.GetSessionIPMEventID(sessionID);

            foreach (var _reserveditem in _reserveditems)
            {
                var _site = placesinmap.GetById(_reserveditem.idRVSite);
                if (_site.idIPMEvent != IPMEventID)
                {
                    _reserveditems = _reserveditems.Where(r => r.idRVSite != _site.ID);
                }
            }

            foreach (var item in _reserveditems)
            {
                // If reserved item is not in the selected item table
                var _checkitem = selecteditems.GetAll().Where(s => s.idRVSite == item.idRVSite && s.reservationAmount != 0).FirstOrDefault();
                if (_checkitem == null)
                {
                    var _site_description_rate = sites_description_rate.GetByKey("id", item.idRVSite);
                    // Add reserved item as selected item
                    selecteditem _selecteditem = new selecteditem();
                    _selecteditem.idRVSite      = item.idRVSite;
                    _selecteditem.idSession     = sessionID;
                    _selecteditem.idIPMEvent    = sessionIPMEventID;
                    _selecteditem.idStaff       = sessionUserID;
                    _selecteditem.idCustomer    = item.idCustomer;
                    _selecteditem.checkInDate   = item.checkInDate;
                    _selecteditem.checkOutDate  = item.checkOutDate;
                    _selecteditem.site          = _site_description_rate.RVSite;
                    _selecteditem.siteType      = _site_description_rate.description;
                    _selecteditem.duration      = item.duration;
                    _selecteditem.weeks         = item.weeks;
                    _selecteditem.weeklyRate    = item.weeklyRate;
                    _selecteditem.days          = item.days;
                    _selecteditem.dailyRate     = item.dailyRate;
                    _selecteditem.amount        = item.total;
                    _selecteditem.isSiteChecked = true;
                    CalcSiteTotal calcResults = new CalcSiteTotal(
                        item.checkInDate,
                        item.checkOutDate,
                        _site_description_rate.weeklyRate.Value,
                        _site_description_rate.dailyRate.Value,
                        true);
                    _selecteditem.duration                = calcResults.duration;
                    _selecteditem.weeks                   = calcResults.weeks;
                    _selecteditem.days                    = calcResults.days;
                    _selecteditem.amount                  = calcResults.amount;
                    _selecteditem.total                   = calcResults.total;
                    _selecteditem.createDate              = DateTime.Now;
                    _selecteditem.lastUpdate              = DateTime.Now;
                    _selecteditem.timeStamp               = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");
                    _selecteditem.idReservationItem       = item.ID;
                    _selecteditem.reservationCheckInDate  = item.checkInDate;
                    _selecteditem.reservationCheckOutDate = item.checkOutDate;
                    _selecteditem.reservationAmount       = item.total;

                    selecteditems.Insert(_selecteditem);
                }
            }
            selecteditems.Commit();

            // Data to be presented on the view

            CreatePaymentViewBags(sessionID, IPMEventID, sessionCustomerID);

            var _selecteditems = selecteditems.GetAll().
                                 Where(si => si.idSession == sessionID && si.idCustomer == sessionCustomerID && si.reservationAmount != 0).
                                 OrderBy(order => order.site);

            return(View(_selecteditems));
        }
Esempio n. 6
0
        public ActionResult SelectSiteOnMap(long id)
        {
            var _session = sessionService.GetSession(this.HttpContext, true, false);

            // Check if site is really available
            bool isRVSiteAvailable = rvsites_available.GetAll().
                                     Where(s => s.idIPMEvent == _session.idIPMEvent && s.id == id).
                                     ToList().Count() > 0;

            if (isRVSiteAvailable)
            {
                ipmevent _IPMEvent = ipmevents.GetById(_session.idIPMEvent);

                // Read dates from IPM Event
                DateTime checkInDate  = _IPMEvent.startDate.Value;
                DateTime checkOutDate = checkInDate.AddDays(7);
                // Read dates from session
                if (_session.checkInDate != null)
                {
                    checkInDate = _session.checkInDate.Value;
                }
                ;
                if (_session.checkOutDate != null)
                {
                    checkOutDate = _session.checkOutDate.Value;
                }
                ;

                // Add selected item to the database
                var _selecteditem = new selecteditem();
                var type_rates    = sites_description_rate.GetAll().
                                    Where(s => s.id == id).FirstOrDefault();

                _selecteditem.checkInDate   = checkInDate;
                _selecteditem.checkOutDate  = checkOutDate;
                _selecteditem.weeklyRate    = type_rates.weeklyRate.Value;
                _selecteditem.dailyRate     = type_rates.dailyRate.Value;
                _selecteditem.idRVSite      = id;
                _selecteditem.idSession     = _session.ID;
                _selecteditem.idIPMEvent    = _session.idIPMEvent;
                _selecteditem.idStaff       = _session.idStaff;
                _selecteditem.idCustomer    = _session.idCustomer;
                _selecteditem.site          = type_rates.RVSite;
                _selecteditem.siteType      = type_rates.description;
                _selecteditem.isSiteChecked = true;
                CalcSiteTotal calcResults = new CalcSiteTotal(
                    checkInDate,
                    checkOutDate,
                    type_rates.weeklyRate.Value,
                    type_rates.dailyRate.Value,
                    true);
                _selecteditem.duration   = calcResults.duration;
                _selecteditem.weeks      = calcResults.weeks;
                _selecteditem.days       = calcResults.days;
                _selecteditem.amount     = calcResults.amount;
                _selecteditem.total      = calcResults.total;
                _selecteditem.createDate = DateTime.Now;
                _selecteditem.lastUpdate = DateTime.Now;
                _selecteditem.timeStamp  = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");

                selecteditems.Insert(_selecteditem);
                selecteditems.Commit();
            }

            return(Json(id));
        }
Esempio n. 7
0
        public ActionResult EditReservation()
        {
            long sessionUserID = sessionService.GetSessionUserID(this.HttpContext);

            ViewBag.UserID = sessionUserID;

            long sessionID         = sessionService.GetSessionID(this.HttpContext);
            long sessionCustomerID = sessionService.GetSessionCustomerID(sessionID);

            ViewBag.Customer = sessionService.GetSessionCustomerNamePhone(sessionID);

            long sessionIPMEventID = sessionService.GetSessionIPMEventID(sessionID);

            var _reserveditems = reservationitems.GetAll();

            if (sessionCustomerID != IDnotFound)
            {
                _reserveditems = _reserveditems.Where(q => q.idCustomer == sessionCustomerID).OrderByDescending(o => o.idRVSite);
            }

            foreach (var item in _reserveditems)
            {
                // If reserved item is not in the selected item table
                var _checkitem = selecteditems.GetAll().Where(s => s.idRVSite == item.idRVSite).FirstOrDefault();
                if (_checkitem == null)
                {
                    var _site_description_rate = sites_description_rate.GetByKey("id", item.idRVSite);
                    // Add reserved item as selected item
                    selecteditem _selecteditem = new selecteditem();
                    _selecteditem.idRVSite      = item.idRVSite;
                    _selecteditem.idSession     = sessionID;
                    _selecteditem.idIPMEvent    = sessionIPMEventID;
                    _selecteditem.idStaff       = sessionUserID;
                    _selecteditem.idCustomer    = item.idCustomer;
                    _selecteditem.checkInDate   = item.checkInDate;
                    _selecteditem.checkOutDate  = item.checkOutDate;
                    _selecteditem.site          = _site_description_rate.RVSite;
                    _selecteditem.siteType      = _site_description_rate.description;
                    _selecteditem.duration      = item.duration;
                    _selecteditem.weeks         = item.weeks;
                    _selecteditem.weeklyRate    = item.weeklyRate;
                    _selecteditem.days          = item.days;
                    _selecteditem.dailyRate     = item.dailyRate;
                    _selecteditem.amount        = item.total;
                    _selecteditem.isSiteChecked = true;
                    CalcSiteTotal calcResults = new CalcSiteTotal(
                        item.checkInDate,
                        item.checkOutDate,
                        _site_description_rate.weeklyRate.Value,
                        _site_description_rate.dailyRate.Value,
                        true);
                    _selecteditem.duration                = calcResults.duration;
                    _selecteditem.weeks                   = calcResults.weeks;
                    _selecteditem.days                    = calcResults.days;
                    _selecteditem.amount                  = calcResults.amount;
                    _selecteditem.total                   = calcResults.total;
                    _selecteditem.createDate              = DateTime.Now;
                    _selecteditem.lastUpdate              = DateTime.Now;
                    _selecteditem.idReservationItem       = item.ID;
                    _selecteditem.reservationCheckInDate  = item.checkInDate;
                    _selecteditem.reservationCheckOutDate = item.checkOutDate;
                    _selecteditem.reservationAmount       = item.total;



                    selecteditems.Insert(_selecteditem);
                }
            }
            selecteditems.Commit();

            // Data to be presented on the view

            CreatePaymentViewBags(sessionID, sessionCustomerID);

            var _selecteditems = selecteditems.GetAll().
                                 Where(s => s.idSession == sessionID && s.idCustomer == sessionCustomerID);

            //payment _payment = paymentService.CalculateEditSelectedTotal(sessionID, sessionCustomerID);

            //// Value of previous reservation, just before edit reservation mode started
            //ViewBag.PrimaryTotal = _payment.primaryTotal.ToString("N2");
            //ViewBag.SelectionTotal = _payment.selectionTotal.ToString("N2");
            //ViewBag.CancellationFee = _payment.cancellationFee.ToString("N2");
            //// Suggested value for payment
            //if (_payment.amount >= 0)
            //{
            //    ViewBag.dueAmount = _payment.amount.ToString("N2");
            //    ViewBag.refundAmount = "0.00";
            //}
            //else
            //{
            //    ViewBag.refundAmount = (_payment.amount * -1).ToString("N2");
            //    ViewBag.dueAmount = "0.00";
            //}

            return(View(_selecteditems));
        }