public async Task <IActionResult> GetWayBillAsync([FromRoute] string id, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (!Guid.TryParse(id, out var guid))
            {
                var error = ErrorResponsesService.NotFoundError(Target, $"WayBill with id '{id}' not found.");
                return(NotFound(error));
            }

            Model.WayBill modelWayBill;

            try
            {
                modelWayBill = await wayBillRepository.GetAsync(guid, cancellationToken).ConfigureAwait(false);
            }
            catch (WayBillNotFoundException)
            {
                var error = ErrorResponsesService.NotFoundError(Target, $"WayBill with id '{id}' not found.");
                return(NotFound(error));
            }

            var driver = await driverRepository.GetAsync(modelWayBill.Driver, cancellationToken).ConfigureAwait(false);

            var clientDriver = ModelConverters.Drivers.DriverConverter.Convert(driver);
            var vehicle      = await vehicleRepository.GetAsync(modelWayBill.Vehicle, cancellationToken).ConfigureAwait(false);

            var clientVehicle = ModelConverters.Vehicles.VehicleConverter.Convert(vehicle);
            var route         = await routeRepository.GetAsync(modelWayBill.Route, cancellationToken).ConfigureAwait(false);

            var checkpoints = await checkpointRepository.GetAllAsync(cancellationToken).ConfigureAwait(false);

            var clientRoute  = ModelConverters.Routes.RouteConverter.Convert(route, checkpoints);
            var mechanicNote = await mechanicNoteRepository.GetAsync(modelWayBill.MechanicNote, cancellationToken)
                               .ConfigureAwait(false);

            var medicNotesCount = route.Checkpoints.Count + 1;
            var medicNotes      = new Models.MedicNotes.MedicNote[medicNotesCount];

            for (var i = 0; i < medicNotesCount; i++)
            {
                medicNotes[i] = await medicNoteRepository.CreateAsync(cancellationToken).ConfigureAwait(false);
            }

            var clientMechanicNote = ModelConverters.MechanicNotes.MechanicNoteConverter.Convert(mechanicNote);
            var clientMedicNotes   = medicNotes.Select(ModelConverters.MedicNotes.MedicNoteConverter.Convert);

            var clientWayBill =
                WayBillConverter.Convert(modelWayBill, clientDriver, clientVehicle, clientRoute, clientMechanicNote, clientMedicNotes);

            return(Ok(clientWayBill));
        }
        public async Task <IActionResult> GetMechanicNoteAsync([FromRoute] string id, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (!Guid.TryParse(id, out var guid))
            {
                var error = ErrorResponsesService.NotFoundError(Target, $"MechanicNote with id '{id}' not found.");
                return(NotFound(error));
            }

            Model.MechanicNote modelMechanicNote;

            try
            {
                modelMechanicNote = await repository.GetAsync(guid, cancellationToken).ConfigureAwait(false);
            }
            catch (MechanicNoteNotFoundException ex)
            {
                var error = ErrorResponsesService.NotFoundError(Target, ex.Message);
                return(NotFound(error));
            }

            var clientMechanicNote = Converter.MechanicNoteConverter.Convert(modelMechanicNote);

            return(Ok(clientMechanicNote));
        }