Пример #1
0
 private async Task IsParked(Guid companyID, Guid vehicleID, bool isInput)
 {
     if (isInput)
     {
         if (await _parkingRepository.AnyAsync(x => x.CompanyID == companyID && x.VehicleID == vehicleID && x.EndDate == null))
         {
             throw new CustomExceptions("Veículo dentro do estacionamento");
         }
     }
     else
     {
         if (!await _parkingRepository.AnyAsync(x => x.CompanyID == companyID && x.VehicleID == vehicleID && x.EndDate == null))
         {
             throw new CustomExceptions("Não há veículo com a placa informada para saída.");
         }
     }
 }
Пример #2
0
        public async Task DeleteAsync(string plate, Guid userID)
        {
            await ValidatePlate(plate, userID);

            var vehicle = await _vehicleRepository.FirstOrDefaultAsync(x => x.Plate.Equals(plate));

            if (await _parkingRepository.AnyAsync(x => x.VehicleID == vehicle.ID))
            {
                throw new CustomExceptions("Não é possível remover este veículo, o mesmo já deu entrada no estaciomento");
            }

            _vehicleRepository.Delete(vehicle);

            await _vehicleRepository.SaveChangeAsync();
        }