Пример #1
0
        //
        // GET: /PropertyPricingSeasonalInstance/Details/5

        public ActionResult Details(int id = 0)
        {
            PropertyPricingSeasonalInstance propertypricingseasonalinstance = db.PropertyPricingSeasonalInstances.Find(id);

            if (propertypricingseasonalinstance == null)
            {
                return(HttpNotFound());
            }
            return(View(propertypricingseasonalinstance));
        }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            PropertyPricingSeasonalInstance propertypricingseasonalinstance = db.PropertyPricingSeasonalInstances.Find(id);

            db.PropertyPricingSeasonalInstances.Remove(propertypricingseasonalinstance);
            db.SaveChanges();

            var propertypricingseasonalinstances = db.PropertyPricingSeasonalInstances.Include(p => p.Property).Include(p => p.PropertyPricingSeason).Where(x => x.PropertyID == id).ToList();

            return(View("Index", propertypricingseasonalinstances));
        }
Пример #3
0
        //
        // GET: /PropertyPricingSeasonalInstance/Edit/5

        public ActionResult Edit(int id = 0)
        {
            PropertyPricingSeasonalInstance propertypricingseasonalinstance = db.PropertyPricingSeasonalInstances.Find(id);

            if (propertypricingseasonalinstance == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PropertyID = new SelectList(db.Properties, "PropertyID", "LegacyReference", propertypricingseasonalinstance.PropertyID);
            ViewBag.PropertyPricingSeasonID = new SelectList(db.PropertyPricingSeasons, "PropertyPricingSeasonID", "Season_Name", propertypricingseasonalinstance.PropertyPricingSeasonID);
            return(View(propertypricingseasonalinstance));
        }
Пример #4
0
 public ActionResult Edit(PropertyPricingSeasonalInstance propertypricingseasonalinstance)
 {
     if (ModelState.IsValid)
     {
         db.Entry(propertypricingseasonalinstance).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", propertypricingseasonalinstance.PropertyID));
     }
     ViewBag.PropertyID = new SelectList(db.Properties, "PropertyID", "LegacyReference", propertypricingseasonalinstance.PropertyID);
     ViewBag.PropertyPricingSeasonID = new SelectList(db.PropertyPricingSeasons, "PropertyPricingSeasonID", "Season_Name", propertypricingseasonalinstance.PropertyPricingSeasonID);
     return(View(propertypricingseasonalinstance));
 }
        /// <summary>
        /// Populates the daterange
        ///
        ///For this price range -
        ///make the start and end dates proper dates (append year from 'theBookingDate'
        ///add start date to list. keep adding dates until enddate (and also add that)
        /// </summary>
        /// <returns></returns>
        ///
        private bool PopulateTheRangeOfDatesBetweenStartAndEndDates(PropertyPricingSeasonalInstance aPropertyPricing)
        {
            try
            {
                //make sure list is blank
                theRangeOfDatesBetweenStartAndEndDates = null;
                theRangeOfDatesBetweenStartAndEndDates = new List <DateTime>();

                CurrentPriceForRange = null;
                CurrentPriceForRange = aPropertyPricing.Price;


                if (aPropertyPricing.PropertyPricingSeason == null)
                {
                    using (var db = new PortugalVillasContext())

                    {
                        aPropertyPricing.PropertyPricingSeason =
                            db.PropertyPricingSeasons.Find(aPropertyPricing.PropertyPricingSeasonID);
                    }
                }


                DateTime startDate = (DateTime)aPropertyPricing.PropertyPricingSeason.SeasonStartDate;
                DateTime endDate   = (DateTime)aPropertyPricing.PropertyPricingSeason.SeasonEndDate;


                int currentDateIterator = (endDate - startDate).Days;
                currentDateIterator -= 1;
                DateTime currentDate = startDate;
                theRangeOfDatesBetweenStartAndEndDates.Add(currentDate);

                //add a day to startdate for the number of days we need, then add this
                for (int i = 0; i <= currentDateIterator; i++)
                {
                    currentDate = currentDate.AddDays(1);
                    theRangeOfDatesBetweenStartAndEndDates.Add(currentDate);
                }


                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #6
0
        public ActionResult Create(PropertyPricingSeasonalInstance propertypricingseasonalinstance)
        {
            if (ModelState.IsValid)
            {
                db.PropertyPricingSeasonalInstances.Add(propertypricingseasonalinstance);
                db.SaveChanges();


                var propertypricingseasonalinstances = db.PropertyPricingSeasonalInstances.Include(p => p.Property).Include(p => p.PropertyPricingSeason).Where(x => x.PropertyID == propertypricingseasonalinstance.PropertyID);
                ViewBag.PropertyID = new SelectList(db.Properties, "PropertyID", "LegacyReference", propertypricingseasonalinstance.PropertyID);
                ViewBag.PropertyPricingSeasonID = new SelectList(db.PropertyPricingSeasons, "PropertyPricingSeasonID", "Season_Name", propertypricingseasonalinstance.PropertyPricingSeasonID);

                return(RedirectToAction("Index", propertypricingseasonalinstance));
            }

            ViewBag.PropertyID = new SelectList(db.Properties, "PropertyID", "LegacyReference", propertypricingseasonalinstance.PropertyID);
            ViewBag.PropertyPricingSeasonID = new SelectList(db.PropertyPricingSeasons, "PropertyPricingSeasonID", "Season_Name", propertypricingseasonalinstance.PropertyPricingSeasonID);
            return(View(propertypricingseasonalinstance));
        }
        //end members

        //////////////////
        //Methods
        //////////////////


        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="theBookingDate"></param>
        /// <param name="propertyID"></param>
        public BookingDateRangeAndPriceCalculator(DateTime theBookingDate, long?propertyID)
        {
            this.theBookingDate = theBookingDate;
            this.PropertyID     = PropertyID;
            this.thePricings    = PropertyPricingSeasonalInstance.GetPricingByPropertyID(propertyID);
        }