Exemplo n.º 1
0
        public async Task GetParkingLotByIdAsync(int?parkingLotId, IOutputPort <GetParkingLotsResponseDTO> outputPort)
        {
            try
            {
                _logger.LogInformation($"Getting parking lot with id {parkingLotId}");

                var parkingLots = new List <ParkingLot>();

                if (parkingLotId != null)
                {
                    parkingLots.Add(await _lotRepo.GetByIdAsync(parkingLotId));
                }

                else
                {
                    parkingLots.AddRange(await _lotRepo.GetAllParkingLotsAsync());
                }


                outputPort.CreateResponse(new GetParkingLotsResponseDTO(parkingLots, true));

                _logger.LogInformation($"Getting parking lot ended sucessfully");
            }
            catch (NotFoundException)
            {
                _logger.LogInformation($"ParkingLot with id {parkingLotId} does not exist");
                outputPort.CreateResponse(new GetParkingLotsResponseDTO(false, new ErrorResponse(new[] { new Error(GlobalErrorCodes.NotFound, $"ParkingLot with id {parkingLotId} does not exist") })));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error while getting parking lot");

                outputPort.CreateResponse(new GetParkingLotsResponseDTO(false, new ErrorResponse(new[] { GlobalErrors.UnexpectedError })));
            }
        }
        private void LoadData()
        {
            list = new List <ParkingLot>();
            var task = Task.Run(async() => list = await _parkingLotsRepository.GetAllParkingLotsAsync());

            task.ContinueWith((t) =>
            {
                if (task.IsCompleted)
                {
                    DayPrice        = list.Find(param => param.ID == "HCMUTEPL").DayPrice.ToString();
                    NightPrice      = list.Find(param => param.ID == "HCMUTEPL").NightPrice.ToString();
                    VIPRequiredTime = list.Find(param => param.ID == "HCMUTEPL").VIPRequiredTime.ToString();
                    VIPDiscount     = list.Find(param => param.ID == "HCMUTEPL").VIPDiscount.ToString();
                }
            });
        }
        private async Task Load()
        {
            _parkingsList = new List <DataAccess.DataModels.Parking>();
            _parkingsList = await _parkingsRepository.GetAllParkingsAsync();

            _customersList = new List <Customer>();
            _customersList = await _customersRepository.GetAllCustomersAsync();

            _parkingLotsList = new List <ParkingLot>();
            _parkingLotsList = await _parkingLotsRepository.GetAllParkingLotsAsync();

            _monthlyIncomesList = new List <MonthlyIncome>();
            _monthlyIncomesList = await _monthlyIncomesRepository.GetMonthlyIncomesAsync();

            _slotsList = new List <Slot>();
            _slotsList = await _slotsRepository.GetAllSlotsAsync();
        }