public bool Validate(BookingRequest br) { return ValidateTravel(br.start_date, br.travel_type_id) && ValidateRooms(br.single_rooms, br.double_rooms); }
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 bool Validate(BookingRequest br) { return(ValidateTravel(br.start_date, br.travel_type_id) && ValidateRooms(br.single_rooms, br.double_rooms)); }