コード例 #1
0
        public async Task BlowVehicle(VehicleTripRegistrationDTO blowVehicleDetails)
        {
            var BlowBus = new VehicleTripRegistration
            {
                PhysicalBusRegistrationNumber = blowVehicleDetails.PhysicalBusRegistrationNumber,
                DepartureDate   = DateTime.UtcNow.Date,
                DriverCode      = blowVehicleDetails.DriverCode,
                IsBlownBus      = true,
                IsVirtualBus    = false,
                JourneyType     = JourneyType.Blown,
                ManifestPrinted = true,
                TripId          = blowVehicleDetails.TripId
            };

            _repo.Insert(BlowBus);

            //await _unitOfWork.SaveChangesAsync();

            //var vehicleTrip = await GetVehicleTripRegistrationDTO(blowVehicleDetails.TripId);
            //this is blow
            var journeyManagement = new JourneyManagement
            {
                VehicleTripRegistrationId = BlowBus.Id,
                JourneyStatus             = JourneyStatus.InTransit,
                JourneyType = JourneyType.Blown,
                JourneyDate = BlowBus?.DepartureDate ?? Clock.Now
            };

            _journeyManagementRepo.Insert(journeyManagement);

            await _unitOfWork.SaveChangesAsync();
        }
コード例 #2
0
        public async Task <IServiceResponse <bool> > CreateBlownBuses(VehicleTripRegistrationDTO blowVehicleDetails)
        {
            return(await HandleApiOperationAsync(async() => {
                await _vtrSvc.BlowVehicle(blowVehicleDetails);

                return new ServiceResponse <bool>(true);
            }));
        }
コード例 #3
0
        public async Task <IServiceResponse <bool> > UpdateBusType(VehicleTripRegistrationDTO manifestManagement)
        {
            return(await HandleApiOperationAsync(async() =>
            {
                await _service.UpdateBusType(manifestManagement);

                return new ServiceResponse <bool>();
            }));
        }
コード例 #4
0
        public async Task <IServiceResponse <bool> > UpateVehicleTrip(VehicleTripRegistrationDTO trip)
        {
            return(await HandleApiOperationAsync(async() =>
            {
                await _vtrSvc.UpdateVehcileTrip(trip);

                return new ServiceResponse <bool>(true);
            }));
        }
コード例 #5
0
        public async Task UpdateVehcileTrip(VehicleTripRegistrationDTO vehicleTripRegistration)
        {
            //var vehicletrips = await _uow.VehicleTripRegistrations.GetAsyncByvId(vehicleTripRegistration.VehicleTripRegistrationId);
            var vehicletrips = await _repo.GetAsync(vehicleTripRegistration.VehicleTripRegistrationId.GetValueOrDefault());

            //_uow.VehicleTripRegistrations.Find(
            //        r => r.VehicleTripRegistrationId == vehicleTripRegistration.VehicleTripRegistrationId)
            //    .FirstOrDefault();

            if (vehicletrips == null)
            {
                throw await _serviceHelper.GetExceptionAsync(ErrorConstants.VEHICLETRIP_NOT_EXIST);
            }


            vehicletrips.PhysicalBusRegistrationNumber = vehicleTripRegistration.PhysicalBusRegistrationNumber;
            vehicletrips.IsVirtualBus = false;
            vehicletrips.DriverCode   = vehicleTripRegistration.DriverCode;
            var email = await _userManagerSvc.FindByNameAsync(_serviceHelper.GetCurrentUserEmail());

            var employee = await _employeeSvc.GetEmployeesByemailAsync(email.Email);

            //Get Assigned Vehicle and Update
            var asignedVehicleDto = await _vehicleSvc.GetVehiclesByRegNum(vehicleTripRegistration.PhysicalBusRegistrationNumber);

            if (asignedVehicleDto == null)
            {
                throw await _serviceHelper.GetExceptionAsync(ErrorConstants.VEHICLE_NOT_EXIST);
            }
            var assignedVehicle = await _vehicleSvc.GetVehicleById(asignedVehicleDto.Id);

            //assignedVehicle.Location = null;
            if (employee != null && employee.TerminalId != null && assignedVehicle.VehicleStatus != VehicleStatus.InWorkshop)
            {
                assignedVehicle.LocationId = employee.TerminalId;
            }
            if (assignedVehicle != null && assignedVehicle.VehicleStatus != VehicleStatus.InWorkshop)
            {
                assignedVehicle.VehicleStatus = VehicleStatus.TerminalUse;
            }
            if (assignedVehicle != null && assignedVehicle.VehicleStatus == VehicleStatus.InWorkshop)
            {
                assignedVehicle.VehicleStatus = VehicleStatus.InWorkshopAndAssigned;
            }
            //Get assigned Captain and Update



            await _unitOfWork.SaveChangesAsync();
        }
コード例 #6
0
        public async Task UpdateBusType(VehicleTripRegistrationDTO manifestManagement)
        {
            decimal amount_to_add   = 0;
            int     originalModelId = manifestManagement.OriginalModelId.GetValueOrDefault();
            int     newModelId      = manifestManagement.VehicleModelId.GetValueOrDefault();

            amount_to_add = await GetFareDifference(manifestManagement.VehicleTripRegistrationId.GetValueOrDefault(), originalModelId, newModelId);

            var manifest = await GetManifestPassengersByVehicleTripIdAsync(manifestManagement.VehicleTripRegistrationId.GetValueOrDefault());

            var existingManifestManagement = await _repository.GetAsync(manifest.Id);

            if (existingManifestManagement == null)
            {
                throw await _serviceHelper.GetExceptionAsync(ErrorConstants.MANIFEST_MANAGEMENT_NOT_EXIST);
            }


            existingManifestManagement.Amount         = existingManifestManagement.Amount + amount_to_add;
            existingManifestManagement.VehicleModelId = newModelId;
            foreach (var seat in manifest.Passengers)
            {
                if (seat.BookingType == BookingTypes.Terminal)
                {
                    var seatMgt = await _seatRepo.GetAsync(seat.Id);

                    seatMgt.Amount = seatMgt.Amount + amount_to_add;
                }
            }

            var existingVehicletrip = await _repo.GetAsync(manifestManagement.VehicleTripRegistrationId.GetValueOrDefault());

            if (existingVehicletrip == null)
            {
                throw await _serviceHelper.GetExceptionAsync(ErrorConstants.VEHICLETRIP_NOT_EXIST);
            }
            existingVehicletrip.VehicleModelId = newModelId;
            await _unitOfWork.SaveChangesAsync();
        }