Beispiel #1
0
 public PaymentService(IConfiguration config,
                       ISunnysideRepo repo,
                       IBookingService bookingService)
 {
     _config         = config;
     _repo           = repo;
     _bookingService = bookingService;
 }
 public CottagesController(ISunnysideRepo repo,
                           IMapper mapper,
                           IConfiguration config)
 {
     _repo   = repo;
     _mapper = mapper;
     _config = config;
 }
Beispiel #3
0
 public PaymentsController(IPaymentService paymentService,
                           ILogger <PaymentsController> logger,
                           ISunnysideRepo repo,
                           IConfiguration config)
 {
     _paymentService = paymentService;
     _logger         = logger;
     _repo           = repo;
     _config         = config;
 }
Beispiel #4
0
 public PendingBookingsController(ISunnysideRepo repo,
                                  IObjectUtilityService objectService,
                                  IMapper mapper,
                                  IConfiguration config)
 {
     _repo          = repo;
     _objectService = objectService;
     _mapper        = mapper;
     _config        = config;
 }
 public AuthController(UserManager <User> userManager,
                       SignInManager <User> signInManager,
                       IMapper mapper,
                       IConfiguration config,
                       ISunnysideRepo repo)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _mapper        = mapper;
     _config        = config;
     _repo          = repo;
 }
 public OwnersController(ISunnysideRepo repo,
                         IMapper mapper)
 {
     _repo   = repo;
     _mapper = mapper;
 }
Beispiel #7
0
 public BookingService(ISunnysideRepo repo)
 {
     _repo = repo;
 }
        public static async Task <List <RegionDto> > SearchRegions(ISunnysideRepo repo,
                                                                   IMapper mapper,
                                                                   int regionId,
                                                                   DateTime?arrivalDate,
                                                                   int nights,
                                                                   int guests)
        {
            List <Region>    regionsToSearch;
            List <RegionDto> regionsWithCapacityAndAvailability = new List <RegionDto>();

            Region regionAndCottages;

            if (regionId == 0)
            {
                regionsToSearch = await repo.GetRegions(false, true, true);
            }
            else
            {
                regionAndCottages = await repo.GetRegionById(regionId, true, true, guests);

                regionsToSearch = new List <Region>()
                {
                    regionAndCottages
                };
            }

            DateTime firstNight = DateTime.MinValue;
            DateTime lastNight  = DateTime.MinValue;

            if (arrivalDate.HasValue)
            {
                firstNight = arrivalDate.Value;
                lastNight  = firstNight.AddDays(nights - 1);
            }


            int nightsAvailable;

            foreach (var region in regionsToSearch)
            {
                var selectedCottages = new List <CottageDto>();
                foreach (var cottage in region.Cottages)
                {
                    if (guests > cottage.MaxGuests)
                    {
                        continue;
                    }

                    if (cottage.Calendar.Count() == 0)
                    {
                        continue;
                    }

                    if (arrivalDate.HasValue)
                    {
                        nightsAvailable = cottage.Calendar
                                          .Where(c => (c.BookingDate >= firstNight && c.BookingDate <= lastNight) &&
                                                 (c.BookingStatus == BookingStatus.Available))
                                          .Count();

                        if (nightsAvailable == nights)
                        {
                            var selectedCottage = mapper.Map <CottageDto>(cottage);
                            selectedCottage.RequestedPrice = Prices.PriceForDates(cottage.Calendar, arrivalDate.Value, nights);
                            selectedCottages.Add(selectedCottage);
                        }
                    }
                    else
                    {
                        var selectedCottage = mapper.Map <CottageDto>(cottage);
                        selectedCottage.MinPrice7Nights = Prices.MinPrice7Nights(cottage.Calendar);
                        selectedCottages.Add(selectedCottage);
                        continue;
                    }
                }

                if (selectedCottages.Count() > 0)
                {
                    var regionToAdd = new RegionDto()
                    {
                        Id       = region.Id,
                        Name     = region.Name,
                        Cottages = selectedCottages
                    };

                    regionsWithCapacityAndAvailability.Add(regionToAdd);
                }
            }

            return(regionsWithCapacityAndAvailability);
        }
 public RegionsController(ISunnysideRepo repo,
                          IMapper mapper)
 {
     _repo   = repo;
     _mapper = mapper;
 }