Exemplo n.º 1
0
        Handle(CheckAvailableParkingSpacesQuery request,
               CancellationToken cancellationToken)
        {
            var data          = _repository.GetById(request.EstablishmentId);
            var establishment = new Establishment(data);

            return(await Task.FromResult(new OccupyParkingSpaceQueryResponse(
                                             establishment.CheckAvailableParkingSpaces()
                                             )));
        }
Exemplo n.º 2
0
        Handle(GetEstablishmentByIdQuery request,
               CancellationToken cancellationToken)
        {
            var result = _repository.GetById(request.Id);

            return(await Task.FromResult(
                       new GetEstablishmentByIdQueryResponse(
                           result.Id,
                           result.Name,
                           result.CNPJ,
                           result.Address.ToString(),
                           result.Phone,
                           result.CarsCapacity,
                           result.MotorcyclesCapacity
                           )
                       ));
        }
Exemplo n.º 3
0
        Handle(ReleaseParkingSpaceRequest request,
               CancellationToken cancellationToken)
        {
            var data = _establishmentRepository
                       .GetById(request.EstablishmentId);

            var establishment = new Establishment(data);
            var totalPrice    = establishment
                                .ReleaseParkingSpace(request.ParkingSpaceId, request.VehicleId);

            _establishmentRepository.Update(establishment.ToDataEntity(request.EstablishmentId));

            _establishmentRepository.CommitChanges();

            return(Task.FromResult(new
                                   ReleaseParkingSpaceResponse(request.ParkingSpaceId,
                                                               request.VehicleId,
                                                               establishment
                                                               .IsParkingSpaceAvailable(request.ParkingSpaceId),
                                                               totalPrice.ToString()
                                                               )
                                   ));
        }
Exemplo n.º 4
0
        Handle(OccupyParkingSpaceRequest request,
               CancellationToken cancellationToken)
        {
            var data = _establishmentRepository
                       .GetById(request.EstablishmentId);

            var establishment = new Establishment(data);

            establishment
            .OccupyParkingSpace(request.ParkingSpaceId, request.VehicleId);

            var result = _establishmentRepository
                         .Update(establishment.ToDataEntity(request.EstablishmentId));

            _establishmentRepository.CommitChanges();

            return(Task.FromResult(new
                                   OccupyParkingSpaceResponse(request.ParkingSpaceId,
                                                              request.VehicleId,
                                                              establishment
                                                              .IsParkingSpaceAvailable(request.ParkingSpaceId)
                                                              )
                                   ));
        }