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