Esempio n. 1
0
        private IEnumerable <LocationSummaryRow> GetReservationCheckOutData(
            Dictionary <DictionaryParameter, string> parameters)
        {
            var locationId = int.Parse(parameters[DictionaryParameter.Location]);
            var nowDate    = DateTime.Now.Date.AddHours(DateTime.Now.Hour);

            var resData = DataContext.Reservations1.Select(d => d);

            resData = ReservationRestriction.RestrictVehicleQueryable(DataContext, resData);

            var checkOutData = from res in resData
                               where res.PickupDate.Date == DateTime.Now.Date &&
                               res.PickupLocationId == locationId
                               group res by res.ReservedCarGroup.car_class_id
                               into groupedData
                               select new LocationSummaryRow
            {
                RowId = groupedData.Key,
                ReservationCheckOutToday     = groupedData.Count(),
                ReservationCheckOutRemaining = groupedData.Count(d => d.PickupDate > nowDate)
            };


            var returned = checkOutData.ToList();

            return(returned);
        }
Esempio n. 2
0
        private List <LocationSummaryForeignRow> GetForeignReservationCheckOutData(
            Dictionary <DictionaryParameter, string> parameters)
        {
            var locationId = int.Parse(parameters[DictionaryParameter.Location]);
            var nowDate    = DateTime.Now.Date.AddHours(DateTime.Now.Hour);

            var resData = DataContext.Reservations1.Select(d => d);

            resData = ReservationRestriction.RestrictVehicleQueryable(DataContext, resData);


            var checkOutData = from res in resData
                               where res.PickupDate.Date == DateTime.Now.Date &&
                               res.PickupLocationId == locationId &&
                               res.ReturnLocation.COUNTRy1.CountryId != res.PickupLocation.COUNTRy1.CountryId
                               group res by res.ReservedCarGroup.CAR_CLASS.CAR_SEGMENT.car_segment1
                               into groupedData
                               select new LocationSummaryForeignRow
            {
                CarSegmentName   = groupedData.Key,
                ReservationCount = groupedData.Count(d => d.PickupDate > nowDate)
            };


            var returned = checkOutData.ToList();

            return(returned);
        }
Esempio n. 3
0
        public IQueryable <Reservation> RestrictReservation()
        {
            var resData = DataContext.Reservations1.Select(d => d);

            resData = ReservationRestriction.RestrictVehicleQueryable(DataContext, resData);

            bool checkOutLogic = Parameters[DictionaryParameter.ReservationCheckOutInDateLogic] == true.ToString();

            var reservedLogic = Parameters.ContainsValueAndIsntEmpty(DictionaryParameter.UpgradedLogic) &&
                                Parameters[DictionaryParameter.UpgradedLogic] == false.ToString();

            if (Parameters.ContainsValueAndIsntEmpty(DictionaryParameter.StartDate))
            {
                var startDate = DateTime.Parse(Parameters[DictionaryParameter.StartDate]);
                var endDate   = DateTime.Parse(Parameters[DictionaryParameter.EndDate]);
                resData = checkOutLogic
                        ? resData.Where(d => d.PickupDate >= startDate && d.PickupDate <= endDate)
                        : resData.Where(d => d.ReturnDate >= startDate && d.ReturnDate <= endDate);
            }

            if (Parameters.ContainsValueAndIsntEmpty(DictionaryParameter.ReservationCustomerName))
            {
                var custName = Parameters[DictionaryParameter.ReservationCustomerName];
                resData = resData.Where(d => d.CustomerName == custName);
            }

            if (Parameters.ContainsValueAndIsntEmpty(DictionaryParameter.ReservationExternalId))
            {
                var externalId = Parameters[DictionaryParameter.ReservationExternalId];
                resData = resData.Where(d => d.ExternalId == externalId);
            }

            if (Parameters.ContainsValueAndIsntEmpty(DictionaryParameter.ReservationFlightNumber))
            {
                var flightNumber = Parameters[DictionaryParameter.ReservationFlightNumber];
                resData = resData.Where(d => d.FlightNumber == flightNumber);
            }

            //Car Fields

            resData = RestrictByCarFields(resData, reservedLogic);

            //Location Fields

            resData = RestrictByLocation(resData, true);
            resData = RestrictByLocation(resData, false);


            return(resData);
        }
Esempio n. 4
0
        public List <VehicleMatchGridRow> GetVehicleMatches(int?reservationId = null)
        {
            var reservations = DataContext.Reservations1.Select(d => d);


            reservations = ReservationRestriction.RestrictVehicleQueryable(DataContext, reservations);



            IQueryable <Vehicle> vehicles;

            if (reservationId == null)
            {
                reservations = reservations.Where(d =>
                                                  d.PickupLocation.country != d.ReturnLocation.country &&
                                                  d.PickupDate.Date < DateTime.Now.Date.AddDays(DaysForReservationMatchFuture));
                vehicles = BaseVehicleDataAccess.GetVehicleQueryable(Parameters, DataContext, true, true);
                vehicles = BaseVehicleDataAccess.RestrictByAdditionalParameters(Parameters, DataContext, vehicles);
            }
            else
            {
                vehicles = DataContext.Vehicles.Select(d => d).Where(d => d.IsFleet);

                vehicles = VehicleRestriction.RestrictVehicleQueryable(DataContext, vehicles);

                reservations = reservations.Where(d => d.ReservationId == reservationId);
            }

            vehicles = VehicleFieldRestrictions.RestrictByMatchPredicament(vehicles);

            var vehicleResCountHolder = from v in vehicles
                                        join r in reservations on new
            {
                Country         = v.OwningCountry,
                LocationGroupId = v.LOCATION.cms_location_group_id
            }
            equals new
            {
                Country         = r.ReturnLocation.country,
                LocationGroupId = r.PickupLocation.cms_location_group_id
            }
            where r.PickupDate > DateTime.Now
            group v by v.VehicleId
            into groupedReservations
            select new { VehicleId = groupedReservations.Key, MatchCount = groupedReservations.Count() };

            IQueryable <VehicleMatchGridRow> matchRowEntities;

            if (reservationId == null)
            {
                matchRowEntities = from v in vehicles
                                   join rch in vehicleResCountHolder on v.VehicleId equals rch.VehicleId into rvch
                                   from rch in rvch.DefaultIfEmpty()
                                   select new VehicleMatchGridRow
                {
                    VehicleId        = v.VehicleId,
                    CarGroup         = v.CarGroup,
                    LastLocation     = v.LastLocationCode,
                    LicensePlate     = v.LicensePlate,
                    ModelDescription = v.ModelDescription,
                    NonRevDays       =
                        v.DaysSinceLastRevenueMovement.HasValue ? v.DaysSinceLastRevenueMovement.Value : 0,
                    OperationalStatusCode = v.Operational_Status.OperationalStatusCode,
                    OwningCountry         = v.OwningCountry,
                    UnitNumber            = v.UnitNumber.HasValue ? v.UnitNumber.Value : 0,
                    ReservationsMatched   = rch == null ? 0 : rch.MatchCount
                };
            }
            else
            {
                matchRowEntities = from v in vehicles
                                   join rch in vehicleResCountHolder on v.VehicleId equals rch.VehicleId
                                   select new VehicleMatchGridRow
                {
                    VehicleId        = v.VehicleId,
                    CarGroup         = v.CarGroup,
                    LastLocation     = v.LastLocationCode,
                    LicensePlate     = v.LicensePlate,
                    ModelDescription = v.ModelDescription,
                    NonRevDays       =
                        v.DaysSinceLastRevenueMovement.HasValue ? v.DaysSinceLastRevenueMovement.Value : 0,
                    OperationalStatusCode = v.Operational_Status.OperationalStatusCode,
                    OwningCountry         = v.OwningCountry,
                    UnitNumber            = v.UnitNumber.HasValue ? v.UnitNumber.Value : 0,
                    ReservationsMatched   = rch.MatchCount
                };
            }


            var returned = ApplyDefaultOrderToVehicles(matchRowEntities).ToList();

            return(returned);
        }