コード例 #1
0
 public BookingService(AuthenticationStateProvider authenticationStateProvider, UserManager <ApplicationUser> userManager, IBookingStorage bookingStorage, TeamService teamService)
 {
     this._authenticationStateProvider = authenticationStateProvider;
     this._userManager    = userManager;
     this._bookingStorage = bookingStorage;
     this._teamService    = teamService;
 }
コード例 #2
0
        // A DI Framework may not compile this type of Injection as Parameter, so, you have to change this to non-static
        public static string OverlappingBookingsExist(Booking booking, IBookingStorage bookingStorage)
        {
            if (booking.Status == "Cancelled")
            {
                return(string.Empty);
            }

            var bookings = bookingStorage.GetActiveBookings(booking.Id);
            // We didn't get the logic below in a separate class because the implementation below is specific to the function here...
            var overlappingBooking =
                bookings.FirstOrDefault(
                    b =>
                    booking.ArrivalDate < b.DepartureDate &&
                    b.ArrivalDate < booking.DepartureDate);

            /*
             * booking.ArrivalDate >= b.ArrivalDate
             * && booking.ArrivalDate < b.DepartureDate
             || booking.DepartureDate > b.ArrivalDate
             ||&& booking.DepartureDate <= b.DepartureDate
             ||These tests don't work correctly...
             */

            return(overlappingBooking == null ? string.Empty : overlappingBooking.Reference);
        }
コード例 #3
0
        public static string OverlappingBookingsExist(Booking booking, IBookingStorage storage)
        {
            if (booking.Status == "Cancelled")
            {
                return(string.Empty);
            }

            var bookings           = storage.GetActiveBookings(booking.Id);
            var overlappingBooking =
                bookings.FirstOrDefault(
                    b =>
                    booking.ArrivalDate < b.DepartureDate &&
                    b.ArrivalDate < booking.DepartureDate);

            return(overlappingBooking == null ? string.Empty : overlappingBooking.Reference);
        }
コード例 #4
0
        public static string OverlappingBookingsExist(Booking booking, IBookingStorage bStorage = null)
        {
            if (booking.Status == "Cancelled")
            {
                return(string.Empty);
            }

            var bookingStorage = bStorage ?? new BookingStorage();
            var bookings       = bookingStorage.GetActiveBookings(booking.Id);

            //bool overlap = tStartA < tEndb && tStartB < tEndA;
            var overlappingBooking =
                bookings.FirstOrDefault(
                    b =>
                    booking.ArrivalDate < b.DepartureDate &&
                    b.ArrivalDate < booking.DepartureDate);

            return(overlappingBooking == null ? string.Empty : overlappingBooking.Reference);
        }
コード例 #5
0
 static BookingHelper()
 {
     _storage = new BookingStorage();
 }