public RavenAwareModuleBuilder(IViewFactory viewFactory, IResponseFormatterFactory responseFormatterFactory, IModelBinderLocator modelBinderLocator, IRavenSessionProvider ravenSessionProvider, IModelValidatorLocator validatorLocator) { this.viewFactory = viewFactory; this.responseFormatterFactory = responseFormatterFactory; this.modelBinderLocator = modelBinderLocator; this.validatorLocator = validatorLocator; _ravenSessionProvider = ravenSessionProvider; }
public AvailabilityModule(IRavenSessionProvider store) { using (var session = store.GetSession()) { Get["/"] = parameters => GetDiaryForWeek(session, DateTime.Now.Date); Get["/month"] = parameters => GetDiaryForMonth(session, DateTime.Now); Get["/day"] = parameters => GetDiaryForDay(session, DateTime.Now.Date); Get[@"/day/(?<day>[\d]{1,2})/(?<month>[\d]{1,2})/(?<year>[\d]{1,4})/"] = parameters => GetDiaryForDay(session, new DateTime(parameters.year, parameters.month, parameters.day)); Get["/month/{month}/{year}"] = parameters => GetDiaryForMonth(session, new DateTime(parameters.year, parameters.month, 1)); Get[@"/(?<day>[\d]{1,2})/(?<month>[\d]{1,2})/(?<year>[\d]{1,4})/"] = parameters => GetDiaryForWeek(session, new DateTime(parameters.year, parameters.month, parameters.day)); } }
public LookupModule(IRavenSessionProvider store) { using (var session = store.GetSession()) { Get["/lookup/rates/for/rooms/{roomId}"] = parameters => { var room = session.Load<Room>("rooms/" + parameters.roomId.ToString()); if (room == null) return new NotFoundResponse(); return Response.AsJson(((Room)room).Rates); }; Get[@"/lookup/occupancy/for/day/{day}/{month}/{year}/"] = parameters => { var dateString = string.Format("{0} {1} {2}", parameters.day, parameters.month, parameters.year); var date = DateTime.Parse(dateString); return View[new DayOccupancyModel { CurrentBookings = DiaryManager.DayCheck(date, session), AllRooms = Room.All(session), Date = date }]; }; Post["/lookup/contact/from/phoneNumber"] = parameters => { var model = this.Bind<ContactLookupForm>(); var contact = Contact.GetByPhone(model.PhoneNumber, session); if (contact == null) return Response.AsJson<Contact>(null); return Response.AsJson(new ContactModel { Id = contact.Id, EmailAddress = contact.EmailAddress, MainContactName = contact.MainContactName, Name = contact.Name, PhoneNumber = model.PhoneNumber, CurrentOwings = string.Format("{0:£0.00}", contact.CurrentlyOverdue(session)) }); }; } }
public EventsSvcBroker(IRavenSessionProvider sessionProvider) { SessionProvider = new RavenSessionProvider(); }
public UserService(IRavenSessionProvider documentSessionProvider, IPasswordService pwd) { db = documentSessionProvider.Get(); passwordService = pwd; }
public BookingModule(IRavenSessionProvider store) { using (var session = store.GetSession()) { Get[@"/booking"] = parameters => { if (ValidBookingQueryString()) return new NotFoundResponse(); var date = new DateTime(Request.Query.year, Request.Query.month, Request.Query.day); string productName = Request.Query.product; var product = session.Query<Product>() .FirstOrDefault(x => x.Name == productName.ToSpacedString()); if (product == null) return new NotFoundResponse(); var rooms = product.RoomsToPickFrom(session); if (product.SelectedForm == Product.FormType.Standard) return View[new StandardFormBookingModel { ProductFriendlyName = product.Name, BookingHint = product.BookingHint, Date = date, CurrentBookings = DiaryManager.DayCheck(date, session), Rooms = rooms, AllRooms = Room.All(session), AvailableAdditionalEquipment = AdditionalEquipment.All(session) }]; if (product.SelectedForm == Product.FormType.Extended) return View[new ExtendedFormBookingModel { ProductFriendlyName = product.Name, BookingHint = product.BookingHint, Date = date, CurrentBookings = DiaryManager.DayCheck(date, session), Rooms = rooms, AllRooms = Room.All(session), AvailableAdditionalEquipment = AdditionalEquipment.All(session) }]; if (product.SelectedForm == Product.FormType.Abbreviated) return View[new AbbreviatedFormBookingModel { ProductFriendlyName = product.Name, BookingHint = product.BookingHint, Date = date, CurrentBookings = DiaryManager.DayCheck(date, session), Rooms = rooms, AllRooms = Room.All(session) }]; return new NotFoundResponse(); }; Get[@"/booking/{bookingId}"] = parameters => { var booking = Booking.Get("booking/" + parameters.bookingId, session) as Booking; if (booking == null) return new NotFoundResponse(); if (booking.Product.SelectedForm == Product.FormType.Standard) return View[new StandardFormBookingModel(booking) { CurrentBookings = DiaryManager.DayCheck(booking.Date, session), Rooms = booking.Product.RoomsToPickFrom(session), AllRooms = Room.All(session), AvailableAdditionalEquipment = AdditionalEquipment.All(session) }]; if (booking.Product.SelectedForm == Product.FormType.Extended) return View[new ExtendedFormBookingModel(booking) { CurrentBookings = DiaryManager.DayCheck(booking.Date, session), Rooms = booking.Product.RoomsToPickFrom(session), AllRooms = Room.All(session), AvailableAdditionalEquipment = AdditionalEquipment.All(session) }]; if (booking.Product.SelectedForm == Product.FormType.Abbreviated) return View[new AbbreviatedFormBookingModel(booking) { CurrentBookings = DiaryManager.DayCheck(booking.Date, session), Rooms = booking.Product.RoomsToPickFrom(session), AllRooms = Room.All(session) }]; return new NotFoundResponse(); }; Get[@"/booking/{bookingId}/NoShow"] = parameters => { var booking = Booking.Get("booking/" + parameters.bookingId, session) as Booking; if (booking == null) return new NotFoundResponse(); booking.NoShow(); booking.Save(session); return true; }; Get[@"/booking/{bookingId}/CheckIn"] = parameters => { var booking = Booking.Get("booking/" + parameters.bookingId, session) as Booking; if (booking == null) return new NotFoundResponse(); booking.CheckIn(); booking.Save(session); return true; }; Post[@"/booking/{bookingId}/cancel"] = parameters => { var booking = Booking.Get("booking/" + parameters.bookingId, session) as Booking; if (booking == null) return new NotFoundResponse(); var model = this.Bind<CancellationModel>(); booking.Cancel(model.CancellationType, model.Reason, DateTime.Now); booking.Save(session); return true; }; Post[@"/booking"] = parameters => SaveBooking(session); Post[@"/booking/{bookingId}"] = parameters => SaveBooking(session); } }
public ApplicationService(IRavenSessionProvider documentSessionProvider) { Db = documentSessionProvider.Get(); }
public PersonSvcBroker(IRavenSessionProvider sessionProvider) { SessionProvider = sessionProvider; }
/// <summary> /// Initializes the Member data broker and the raven db components /// </summary> public PersonSvcBroker() { SessionProvider = new RavenSessionProvider(); }