public IQueryable <Booking> GetActiveBookings(Booking booking)
        {
            var bookings = _unitOfWork.Query <Booking>()
                           .Where(
                b => b.Id != booking.Id && b.Status != "Cancelled");

            return(bookings);
        }
Example #2
0
        public IQueryable <Booking> GetBookings()
        {
            var unitOfWork = new UnitOfWork();
            var bookings   =
                unitOfWork.Query <Booking>();

            return(bookings);
        }
Example #3
0
        public IQueryable <Booking> GetActiveBookings(int?excludeBookingId = null)
        {
            var unitOfWork = new UnitOfWork();
            var bookings   = unitOfWork.Query <Booking>()
                             .Where(b => b.Status != "Cancelled" && (excludeBookingId == null || excludeBookingId != b.Id));

            return(bookings);
        }
Example #4
0
        public static void SendStatementEmails(DateTime statementDate)
        {
            var housekeepers = UnitOfWork.Query <Housekeeper>();

            foreach (var housekeeper in housekeepers)
            {
                SendStatementEmail(statementDate, housekeeper);
            }
        }
Example #5
0
        public IQueryable <Booking> GetActiveBookings(int?excludedBookingId = null)
        {
            var unitOfWork = new UnitOfWork();
            var bookings   = unitOfWork
                             .Query <Booking>()
                             .Where(b => (!excludedBookingId.HasValue || b.Id != excludedBookingId.Value) && b.Status != "Cancelled");

            return(bookings);
        }
        public IQueryable <Booking> GetActiveBookings(int excludedBooking)
        {
            var unitOfWork = new UnitOfWork();

            return
                (unitOfWork.Query <Booking>()
                 .Where(
                     b => b.Id != excludedBooking && b.Status != "Cancelled"));
        }
Example #7
0
        public IQueryable <Booking> FindActiveBookings(int excludedBookingId)
        {
            var unitOfWork = new UnitOfWork();
            var bookings   =
                unitOfWork.Query <Booking>()
                .Where(
                    b => b.Id != excludedBookingId && b.Status != "Cancelled");

            return(bookings);
        }
Example #8
0
        public IQueryable <Booking> getBookings(Booking booking)
        {
            var unitOfWork = new UnitOfWork();
            var bookings   =
                unitOfWork.Query <Booking>()
                .Where(
                    b => b.Id != booking.Id && b.Status != "Cancelled");

            return(bookings);
        }
        public IQueryable <Booking> GetActiveBookings(int?exculdeBookingId = null)
        {
            var unitOfWork = new UnitOfWork();

            var bookings = unitOfWork.Query <Booking>()
                           .Where(
                b => b.Status != "Cancelled");

            return(exculdeBookingId.HasValue ? bookings.Where(b => b.Id != exculdeBookingId) : bookings);
        }
Example #10
0
        public IQueryable <Booking> GetBookings(int?id = null)
        {
            var unitOfWork = new UnitOfWork();
            var bookings   = unitOfWork.Query <Booking>().Where(b => b.Status != "Cancelled");

            if (id.HasValue)
            {
                bookings = bookings.Where(b => b.Id != id.Value);
            }
            return(bookings);
        }
Example #11
0
        public IQueryable <Booking> getActiveBookings(int?excludedBookingId)
        {
            var unitOfWork = new UnitOfWork();
            var bookings   = unitOfWork.Query <Booking>()
                             .Where(
                b => b.Id != excludedBookingId &&
                b.Status != "Cancelled");

            if (excludedBookingId.HasValue)
            {
                bookings = bookings.Where(b => b.Id != excludedBookingId.Value);
            }
            return(bookings);
        }
Example #12
0
        public IQueryable <Booking> GetActiveBookings(int?excludedBookingId = null)
        {
            var bookings =
                _unitOfWork.Query <Booking>()
                .Where(
                    b => b.Status != "Cancelled");

            if (excludedBookingId.HasValue)
            {
                bookings = bookings.Where(b => b.Id == excludedBookingId.Value);
            }

            return(bookings);
        }
Example #13
0
        public IQueryable <Booking> GetActiveBookings(int?excludedBookingId = null) // we wanted this to be optional
        {
            var unitOfWork = new UnitOfWork();                                      // External Database, so, External resource used...
            var bookings   =
                unitOfWork.Query <Booking>()
                .Where(
                    b => b.Status != "Cancelled");

            if (excludedBookingId.HasValue)
            {
                bookings = bookings.Where(b => b.Id != excludedBookingId.Value);
            }

            return(bookings);
        }
Example #14
0
        public string OverlappingBookingsExist(Booking booking)
        {
            if (booking.Status == "Cancelled")
            {
                return(string.Empty);
            }

            var otherNotCancelledBookings = _unitOfWork
                                            .Query <Booking>()
                                            .Where(b => b.Id != booking.Id && b.Status != "Cancelled");

            var overlappingBooking = otherNotCancelledBookings
                                     .FirstOrDefault(b => IsBookingsOverlapped(booking, b));

            return(overlappingBooking == null ? string.Empty : overlappingBooking.Reference);
        }
        public IQueryable <Booking> GetActiveBookings(int?excludedBookingId = null)
        {
            var unitOfWork = new UnitOfWork();
            //Refactorizamos esta dependencia externa en una clase a parte
            var bookings =
                unitOfWork.Query <Booking>()
                .Where(
                    b => b.Status != "Cancelled");

            if (excludedBookingId.HasValue)
            {
                bookings = bookings.Where(b => b.Id != excludedBookingId.Value);
            }

            return(bookings);
        }
Example #16
0
        public static string OverlappingBookingsExist(Booking booking)
        {
            if (booking.Status == "Cancelled")
            {
                return(string.Empty);
            }

            var unitOfWork = new UnitOfWork();
            var bookings   = unitOfWork.Query <Booking>()
                             .Where(b => b.Id != booking.Id && b.Status != "Cancelled");

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

            return(overlappingBooking == null ? string.Empty : overlappingBooking.Reference);
        }
Example #17
0
 public IQueryable <Housekeeper> GetHouseKeepers()
 {
     return(_unitOfWork.Query <Housekeeper>());
 }
Example #18
0
        public IQueryable <Housekeeper> GetHouseKeepers()
        {
            var housekeepers = _unitOfWork.Query <Housekeeper>();

            return(housekeepers);
        }
Example #19
0
 public IQueryable <Booking> GetAllBookingsWithActiveStatusAndDifferentByGivenId(int id)
 => _unitOfWork.Query <Booking>()
 .Where(
     b => b.Id != id && b.Status != "Cancelled");
Example #20
0
        public IQueryable <Housekeeper> GetHousekeepers()
        {
            UnitOfWork UnitOfWork = new UnitOfWork();

            return(UnitOfWork.Query <Housekeeper>());
        }