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); }
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; } }