Example #1
0
        public static string OverlappingBookingsExist(Booking booking, IBookingRepository bookingRepository)
        {
            if (booking.Status == "Cancelled")
            {
                return(string.Empty);
            }


            //var unitOfWork = new UnitOfWork();
            //Refactorizamos esta dependencia externa en una clase a parte
            //var bookings =
            //    unitOfWork.Query<Booking>()
            //        .Where(
            //            b => b.Id != booking.Id && b.Status != "Cancelled");

            var bookings = bookingRepository.GetActiveBookings(booking.Id);

            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  // ESTE CODIGO TIENE BUGS DETECTADOS POR EL UNIT TESTING
                    );

            return(overlappingBooking == null ? string.Empty : overlappingBooking.Reference);
        }
 public NormalUserController(UserManager <ApplicationUser> _userManager, IBookingRepository _bookingRepository, ISportshallRepository _sportshallRepository, IActivityRepository _activityRepository)
 {
     bookingRepository    = _bookingRepository;
     sportshallRepository = _sportshallRepository;
     activityRepository   = _activityRepository;
     userManager          = _userManager;
 }
 public TripController(ITripRepository tripRepository, IVehicleRepository vehicleRepository, IBookingRepository bookingRepository, ILogger <TripController> logger)
 {
     _tripRepository    = tripRepository;
     _vehicleRepository = vehicleRepository;
     _bookingRepository = bookingRepository;
     _logger            = logger;
 }
Example #4
0
        public static string OverlappingBookingsExist(Booking booking, IBookingRepository repository)
        {
            if (booking.Status == "Cancelled")
            {
                return(string.Empty);
            }

            var bookings = repository.GetActiveBooking(booking.Id);

            //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.DepartureDate &&
                    b.ArrivalDate < booking.DepartureDate);

            return(overlappingBooking == null ? string.Empty : overlappingBooking.Reference);


            //        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 #5
0
 public BookingsController(IBookingRepository db1, IAccesoryRepository db2, IAnimalRepository db3, ICustomerRepository db4)
 {
     this.dbBooking   = db1;
     this.dbAccessory = db2;
     this.dbAnimal    = db3;
     this.dbCustomer  = db4;
 }
        public ActionResult Booking()
        {
            Session["roomNr"] = null;

            if (IsLoggedIn())
            {
                try
                {
                    Booking b = new Booking();
                    bookingRepository = new BookingRepositoryDB();
                    bookingRepository.Open();
                    List <decimal> prices = bookingRepository.GetPrices();
                    b.PriceOneBed    = prices[0];
                    b.PriceTwoBeds   = prices[1];
                    b.PriceThreeBeds = prices[2];
                    return(View(b));
                }
                catch (Exception)
                {
                    return(View("Message", new Message("Buchung", "Beim Anzeigen der Seite ist ein Fehler aufgetreten")));
                }
                finally
                {
                    bookingRepository.Close();
                }
            }
            else
            {
                TempData["Message"] = "login";
                return(View("Message", new Message("Zimmer buchen", "Bitte melden Sie sich zuerst an um ein Zimmer zu buchen")));
                //TempData["Message"] = "Sie müssen sich anmelden um ein Zimmer zu buchen";
                //return RedirectToAction("Login", "User");
            }
        }
 public AccommodationLogic(IAccommodationRepository accommodationRepository, ITouristicSpotRepository spotRepository, IReviewRepository reviewRepository, IBookingRepository bookingRepository)
 {
     this.accommodationRepository = accommodationRepository;
     this.spotRepository          = spotRepository;
     this.reviewRepository        = reviewRepository;
     this.bookingRepository       = bookingRepository;
 }
 public ActionResult ShowBookings()
 {
     if (IsLoggedIn())
     {
         try
         {
             bookingRepository = new BookingRepositoryDB();
             bookingRepository.Open();
             if (Session["id"] != null)
             {
                 List <Booking> bookings = bookingRepository.GetBookingsOneUser(Convert.ToInt32(Session["id"]));
                 return(View(bookings));
             }
             else
             {
                 return(View("Message", new Message("Buchungen", "Beim anzeigen ihrer Buchungen ist ein Fehler aufgetreten", "Versuchen Sie es später nochmal")));
             }
         }
         catch (Exception)
         {
             return(View("Message", new Message("Buchungen", "Beim anzeigen ihrer Buchungen ist ein Fehler aufgetreten", "Versuchen Sie es später nochmal")));
         }
         finally
         {
             bookingRepository.Close();
         }
     }
     else
     {
         return(View("Message", new Message("URL Fehler", "Die angegebene URL ist ungültig")));
     }
 }
Example #9
0
 public CreateBookingHandler(IBookingRepository bookingRepository,
                             IRoomRepository roomRepository,
                             IDomainEvents domainEvents) : base(domainEvents)
 {
     _bookingRepository = bookingRepository;
     _roomRepository    = roomRepository;
 }
Example #10
0
 public ScraperService(IScraperRepository scraperRepository, IClassroomRepository classroomRepository, IClassRepository classRepository, IBookingRepository bookingRepository)
 {
     ScraperRepository   = scraperRepository;
     ClassroomRepository = classroomRepository;
     ClassRepository     = classRepository;
     BookingRepository   = bookingRepository;
 }
Example #11
0
 public WebScraper(IClassroomRepository classroomRepository, IBookingRepository bookingRepository, IClassRepository classRepository, IScraperRepository scraperRepository)
 {
     ClassroomRepository = classroomRepository;
     BookingRepository   = bookingRepository;
     ClassRepository     = classRepository;
     ScraperRepository   = scraperRepository;
 }
Example #12
0
 public BookManager(
     IBookRepository <Book> repository,
     IBookingRepository <Booking> bookingRepository)
 {
     _repository        = repository;
     _bookingRepository = bookingRepository;
 }
Example #13
0
 public Seed(IUserRepository userRepository, IWeekRepository weekRepository, IBookingRepository bookingRepository, App42Context ctx)
 {
     _userRepository    = userRepository;
     _weekRepository    = weekRepository;
     _bookingRepository = bookingRepository;
     _context           = ctx;
 }
 public BookingService(IBookingRepository repository, IMapper mapper, IAdministratorRepository repositoryAdmin, IVisitorRepository visitorRepository)
 {
     _repository        = repository;
     _mapper            = mapper;
     _repositoryAdmin   = repositoryAdmin;
     _visitorRepository = visitorRepository;
 }
 //[HttpPost]
 public ActionResult ShowBookings(int?userId)
 {
     if (IsAdmin() && (userId != null))
     {
         try
         {
             bookingRepository = new BookingRepositoryDB();
             bookingRepository.Open();
             List <Booking> bookings;
             if (userId == -1)
             {
                 bookings = bookingRepository.GetAllBookings();
             }
             else
             {
                 TempData["Message"] = "oneUser";
                 bookings            = bookingRepository.GetBookingsOneUser(Convert.ToInt32(userId));
             }
             return(View(bookings));
         }
         catch (Exception)
         {
             return(View("Message", new Message("Alle Buchungen anzeigen", "Beim Anzeigen der Buchungen ist ein Fehler aufgetreten")));
         }
         finally
         {
             bookingRepository.Close();
         }
     }
     else
     {
         return(View("Message", new Message("URL Fehler", "Die angegebene URL ist ungültig")));
     }
 }
Example #16
0
        public BookingController(IBookingRepository db, ICustomerRepository db2, ApplicationDbContext _context)
        {
            this.db  = db;
            this.db2 = db2;

            this._context = _context;
        }
Example #17
0
 public CarOperationHandler(ICarRepository carRepository, IBookingRepository bookingRepository, ICurrencyConverterHandler currencyConverterHandler, IUserOperationHandler userOperationHandler)
 {
     this.carRepository            = carRepository;
     this.bookingRepository        = bookingRepository;
     this.currencyConverterHandler = currencyConverterHandler;
     this.userOperationHandler     = userOperationHandler;
 }
Example #18
0
        public AdminController(IBookingRepository bookingRepository, IAdminRepository adminRepository)
        {
            _logger = NLog.LogManager.GetCurrentClassLogger();

            _adminRepository   = adminRepository;
            _bookingRepository = bookingRepository;
        }
Example #19
0
        public int AmountOfMaintenanceBookings(IBookingRepository bookingRepository, int week)
        {
            var allRooms   = bookingRepository.GetAllMaintenanceBookings(week);
            var statistics = allRooms.Count;

            return(statistics);
        }
 public ActionResult DeleteBooking(int idToDelete)
 {
     if (IsAdmin())
     {
         try
         {
             bookingRepository = new BookingRepositoryDB();
             bookingRepository.Open();
             if (bookingRepository.Delete(idToDelete))
             {
                 return(View("Message", new Message("Buchung Löschen", "Die Buchung wurde erfolgreich gelöscht")));
             }
             else
             {
                 return(View("Message", new Message("Buchung Löschen", "Die Buchung konnte nicht gelöscht werden")));
             }
         }
         catch (Exception)
         {
             return(View("Message", new Message("Buchung Löschen", "Die Buchung konnte nicht gelöscht werden")));
         }
         finally
         {
             bookingRepository.Close();
         }
     }
     else
     {
         return(View("Message", new Message("URL Fehler", "Die angegebene URL ist ungültig")));
     }
 }
 public ActionResult SetPrices()
 {
     if (IsAdmin())
     {
         try
         {
             bookingRepository = new BookingRepositoryDB();
             bookingRepository.Open();
             List <decimal> prices = bookingRepository.GetPrices();
             return(View(prices));
         }
         catch (Exception)
         {
             return(View("Message", new Message("Preise ändern", "Fehler beim Verarbeiten der Daten")));
         }
         finally
         {
             bookingRepository.Close();
         }
     }
     else
     {
         return(View("Message", new Message("URL Fehler", "Die angegebene URL ist ungültig")));
     }
 }
Example #22
0
 public BookingServiceTests()
 {
     _fixture           = new Fixture();
     _bookingRepository = Substitute.For <IBookingRepository>();
     _tableRepository   = Substitute.For <IRepository <Table> >();
     _service           = new BookingService(_bookingRepository, _tableRepository);
 }
        public ActionResult BookingConfirmation(Booking booking)
        {
            try
            {
                booking        = Session["booking"] as Booking;
                booking.IdUser = Session["id"] != null?Convert.ToInt32(Session["id"]) : -1;

                booking.RoomNr = Session["roomNr"] != null?Convert.ToInt32(Session["roomNr"]) : -1;

                bookingRepository = new BookingRepositoryDB();
                bookingRepository.Open();
                if (bookingRepository.Insert(booking))
                {
                    return(View("Message", new Message("Buchung", "Die Buchung war erfolgreich")));
                }
                else
                {
                    return(View("Message", new Message("Buchung", "Es ist ein Fehler bei ihrer Buchung aufgetreten", "Versuchen Sie es später nocheinmal")));
                }
            }
            catch (Exception ex)
            {
                return(View("Message", new Message("Buchung", "Es ist ein Fehler bei ihrer Buchung aufgetreten")));
            }
            finally
            {
                Session["booking"] = null;
                Session["roomNr"]  = null;
                bookingRepository.Close();
            }
        }
        public static string OverlappingBookingsExist(Booking booking, IBookingRepository repository)
        {
            if (booking.Status == "Cancelled")
            {
                return(string.Empty);
            }

            // var bookings = repository.GetActiveBookings(booking.Id);

            var bookingsTest = new List <Booking>
            {
                new Booking
                {
                    Id            = 2,
                    ArrivalDate   = new DateTime(2020, 1, 10, 14, 0, 0),
                    DepartureDate = new DateTime(2020, 1, 15, 10, 0, 0),
                    Reference     = "a"
                }
            };
            var overlappingBooking =
                bookingsTest.FirstOrDefault(
                    b =>
                    booking.ArrivalDate < b.DepartureDate &&
                    b.ArrivalDate < booking.DepartureDate);

            return(overlappingBooking == null ? string.Empty : overlappingBooking.Reference);
        }
Example #25
0
 public MISRepository(IOptions <MongoSettings> settings, IConfiguration configuration, IGenericRepository genericRepository, IBookingRepository bookingRepository)
 {
     _MongoContext      = new MongoContext(settings);
     _genericRepository = genericRepository;
     _configuration     = configuration;
     _bookingRepository = bookingRepository;
 }
 public GetPendingForVehicleViewModelMapper(
     IBookingRepository bookingRepository,
     ICustomerServiceProxy customerServiceProxy)
 {
     _bookingRepository = bookingRepository;
     _customerServiceProxy = customerServiceProxy;
 }
 public void Init()
 {
     _dbContext       = new FlightDbContext("FlightDbContext");
     _bookingRep      = new BookingRepository(_dbContext, new FlightRepository(_dbContext));
     _lastBookingId   = _dbContext.Bookings.Max(b => b.Id);
     _lastPassengerId = _dbContext.Passengers.Max(p => p.Id);
 }
 public ActionResult SetPrices(List <decimal> prices)
 {
     ValidatePrices(prices);
     if (ModelState.IsValid)
     {
         try
         {
             bookingRepository = new BookingRepositoryDB();
             bookingRepository.Open();
             if (bookingRepository.SetPrices(prices))
             {
                 return(View("Message", new Message("Preise ändern", "Die Preise wurden erfolgreich geändert")));
             }
             else
             {
                 return(View("Message", new Message("Preise ändern", "Die Preise konnten nicht geändert werden")));
             }
         }
         catch (Exception)
         {
             return(View("Message", new Message("Preise ändern", "Die Preise konnten nicht geändert werden")));
         }
         finally
         {
             bookingRepository.Close();
         }
     }
     else
     {
         return(View());
     }
 }
Example #29
0
        public int AmountOfBookings(IBookingRepository repository)
        {
            var allBookings = repository.GetAllBookings();
            var statistics  = allBookings.Count;

            return(statistics);
        }
Example #30
0
 public LocationService(ICustomerLocationRepository locationRepository, IBookingRepository bookingRepository, ICityRepository cityRepository, IDistrictRepository districtRepository)
 {
     _locationRepository = locationRepository;
     _bookingRepository  = bookingRepository;
     _cityRepository     = cityRepository;
     _districtRepository = districtRepository;
 }
 public BookingsCollectionController(IMapper mapper,
                                     IBookingRepository bookingRepository)
 {
     _mapper            = mapper ?? throw new ArgumentNullException(nameof(mapper));
     _bookingRepository = bookingRepository ??
                          throw new ArgumentNullException(nameof(bookingRepository));;
 }
Example #32
0
 private static void rlist(IBookingRepository i)
 {
     foreach (var a in i.GetAllBookingsDetails())
     {
         System.Console.WriteLine(a.CustName);
         System.Console.WriteLine(a.BookingTime);
     }
 }
 public IndexViewModelMapper(
     IUserProvider userProvider,
     IBookingRepository bookingService,
     ICustomerServiceProxy customerServiceProxy,
     IVehicleServiceProxy vehicleServiceProxy)
 {
     _userProvider = userProvider;
     _bookingService = bookingService;
     _customerServiceProxy = customerServiceProxy;
     _vehicleServiceProxy = vehicleServiceProxy;
 }
 public BookingController(
     IIndexViewModelMapper indexViewModelMapper,
     IMakeViewModelMapper makeViewModelMapper,
     IGetPendingForVehicleViewModelMapper getPendingForVehicleViewModelMapper,
     IBookingRepository bookingRepository)
 {
     _indexViewModelMapper = indexViewModelMapper;
     _makeViewModelMapper = makeViewModelMapper;
     _getPendingForVehicleViewModelMapper = getPendingForVehicleViewModelMapper;
     _bookingRepository = bookingRepository;
 }
Example #35
0
 public BookingService(IBookingRepository repository)
 {
     _repository = repository;
 }
Example #36
0
 /// <summary>
 /// Initialize the Service
 /// </summary>
 public BookingService()
 {
     _bookingRepository = new BookingRepository();
     _roomRepository = new RoomRepository();
 }
 public BookingService(IBookingRepository bookingRepository, IUnitOfWork unitOfWork)
 {
     BookingRepository = bookingRepository;
     UnitOfWork = unitOfWork;
 }
 public BookingService(IBookingRepository bookingRepository)
 {
     this.bookingRepository = bookingRepository;
 }
 public void SetUp()
 {
     _contextProvider = TestRegistry.Kernel.Get<IContextProvider>();
     _bookingRepository = TestRegistry.Kernel.Get<IBookingRepository>();
     ScriptRunner.RunScript();
 }
 public BookingComponent()
 {
     bookingRepository = new BookingRepository(new SqlConnection(ConfigurationManager.ConnectionStrings["usrMgmtConnString"].ConnectionString));
 }
 public AdvertisementBookingController(IBookingRepository repo)
 {
     this._repo = repo;
 }
Example #42
0
 public CargoBookings(IIntegerSequenceGenerator integerSequenceGenerator, IBookingRepository bookingRepository, IBookingConsole console)
 {
     _integerSequenceGenerator = integerSequenceGenerator;
     _bookingRepository = bookingRepository;
     _console = console;
 }