public ActionResult AddExtraToBooking(Guid booking_id, int extra_id, int number, DateTime extra_date) { Cart cart = new Cart(); ExtraBooking extraBooking = new ExtraBooking(); extraBooking.extra_id = extra_id; extraBooking.participants = number; extraBooking.booked_date = extra_date; Extra extra = cart.ctx.Extras.FirstOrDefault(x => x.id == extra_id); extraBooking.Extra = extra; cart.GetBooking(booking_id).ExtraBookings.Add(extraBooking); return PartialView("_ExtraBookingCartPartial", cart.GetBooking(booking_id).ExtraBookings); }
public JsonResult UpdateBooking(BookingRequest br) { Cart cart = new Cart(); BookingValidator v = new BookingValidator(); v.Validate(br); List<String> errors = v.errors; foreach (ModelState state in ModelState.Values) foreach (ModelError error in state.Errors) errors.Add(error.ErrorMessage); Boolean success = errors.Count == 0; if (success) { Booking b = cart.GetBooking(br.booking_id); //b.guests = br.guests; b.single_rooms = br.single_rooms; b.double_rooms = br.double_rooms; b.duration = br.duration; b.start_date = br.start_date; if (User.Identity.IsAuthenticated) { if (User.IsInRole("TelesaleStaff")) { b.booker_id = (System.Guid)Membership.GetUser().ProviderUserKey; Customer c = (Customer) System.Web.HttpContext.Current.Session["customer"]; b.customer_id = c.MembershipID; } else//normal customer { b.customer_id = (System.Guid)Membership.GetUser().ProviderUserKey; } } b.Travel.TravelType = cart.ctx.TravelTypes.SingleOrDefault(t => t.id == br.travel_type_id); b.Travel.departure = br.start_date; b.Travel.arrival = br.start_date; foreach (Passanger p in b.Travel.Passangers.ToList()) { b.Travel.Passangers.Remove(p); cart.ctx.DeleteObject(p); } //b.Travel.Passangers.Clear(); for (int i = 0; i < b.guests(); i++) { b.Travel.Passangers.Add(new Passanger { id = Guid.NewGuid() }); } } return Json(new { success = success, id = br.booking_id , errors = errors}); }
public ActionResult RemoveBookingFromCart(Guid booking_id) { Cart cart = new Cart(); cart.ctx.DeleteObject(cart.GetBooking(booking_id)); return PartialView("_CartPartial", cart); }