/// <summary> /// Constructor to populate properties from the accompaning /// private methods /// </summary> /// <param name="regularId"></param> public ShoppingCartService(int regularId) { this.regular = db.Regulars.Find(regularId); this.guestCount = countGuests(); this.totalCost = calculateTripCost(); this.pickUpTime = convertPickupTime(); this.returnTime = convertReturnTime(); }
private string endDate(Regular regular) { DateTime newEndDate; TimeSpan time; if(regular.ReturnTrips.Count > 0) time = regular.ReturnTrips.First().PickupTime.Value; else { switch (regular.TripType.Name) { case "Airport": time = regular.PickupTime.Add(TimeSpan.FromHours(2)); break; case "Downtown": time = regular.PickupTime.Add(TimeSpan.FromHours(1.5)); break; case "North Charleston": time = regular.PickupTime.Add(TimeSpan.FromHours(3)); break; case "West Ashley": time = regular.PickupTime.Add(TimeSpan.FromHours(1.5)); break; case "Daniel Island": time = regular.PickupTime.Add(TimeSpan.FromHours(3)); break; case "Mt. Pleasant": time = regular.PickupTime.Add(TimeSpan.FromHours(3)); break; default: time = regular.PickupTime.Add(TimeSpan.FromHours(1)); break; } } newEndDate = regular.Date.Add(time); return newEndDate.ToString("yyyy-MM-ddTHH:mm:ssZ"); }
public ActionResult Create([Bind(Include = "TripTypeId,Date,HHID,MemberId,KiawahLocation,OtherAddress,TripLocation,NonKiawahPickup,DriverId,VehicleId,PickupTime,OfficerName,Email,Phone,Notes")] RegularViewModel vm, string[] Members) { //If no members have been entered, the string array will return null. //To stop this, I have written initialized the array to allow it to be counted in the next //code segment. string otheraddress = vm.OtherAddress; if (vm.KiawahLocation == "Other") { vm.KiawahLocation = otheraddress; } Regular regular = new Regular() { TripTypeId = vm.TripTypeId, Date = vm.Date, HHID = vm.HHID, MemberId = vm.MemberId, KiawahLocation = vm.KiawahLocation, TripLocation = vm.TripLocation, NonKiawahPickup = vm.NonKiawahPickup, DriverId = vm.DriverId, VehicleId = vm.VehicleId, PickupTime = vm.PickupTime, OfficerName = vm.OfficerName, Email = vm.Email, Phone = vm.Phone, Notes = vm.Notes, otherAddress = vm.OtherAddress }; if (Members == null) { Members = new string[] { }; } //This checks to be sure the model is valid before creating it if (ModelState.IsValid) { //If there are Members that have been entered into the //trip, this adds them to the object if (Members.Count() != 0) { foreach (var item in Members) { int intitem = Convert.ToInt32(item); Member member = db.Members.Find(intitem); regular.Members.Add(member); } } //Recovers the id for the return trip int regularId = regular.Id; //regular.Count = meth.CountGuests(regularId); //regular.Cost = meth.calculateTripCost(regularId); db.Regulars.Add(regular); db.SaveChanges(); Regular regularobject = db.Regulars.Find(regular.Id); int hhid = regular.HHID; return View("Details", regularobject); } //If the model is not valid, have them re-enter all the information ViewBag.MemberList = memberList(regular.HHID, null); ViewBag.KiawahLocation = GetAddressList(regular.HHID, null); ViewBag.DriverId = new SelectList(db.Drivers, "Id", "Name", regular.DriverId); ViewBag.TripTypeId = new SelectList(db.TripTypes, "Id", "Name", regular.TripTypeId); ViewBag.VehicleId = new SelectList(db.Vehicles, "Id", "Name", regular.VehicleId); return View(vm); }
private string Text(Regular regular) { string text; return text = regular.TripType.Name + " - " + regular.TripLocation + System.Environment.NewLine + regular.Household.Name + System.Environment.NewLine + "Guests: " + meth.CountGuests(regular.Id) + "/10"; }
private string startDate(Regular regular) { DateTime newStartDate; newStartDate = regular.Date.Add(regular.PickupTime); return newStartDate.ToString("yyyy-MM-ddTHH:mm:ssZ"); }