Ejemplo n.º 1
0
        /// <inheritdoc cref="IFlightSection.DeleteReturnAsync(long, long, CancellationToken)"/>
        public async Task DeleteReturnAsync(long id, long returnFlightId, CancellationToken ct = default)
        {
            var requestUri = Endpoint.AppendPathSegments(id, "returns", returnFlightId);

            using var response = await HttpClient.DeleteAsync(requestUri, ct).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();
        }
Ejemplo n.º 2
0
        /// <inheritdoc cref="IFlightSection.SetStatusAsync(long, short, CancellationToken)"/>
        public async Task SetStatusAsync(long id, short statusId, CancellationToken ct = default)
        {
            var requestUri = Endpoint.AppendPathSegments(id, "status");
            var body       = new StringContent(JsonSerializer.Serialize(statusId), Encoding.UTF8, MediaTypeNames.Application.Json);

            using var response = await HttpClient.PatchAsync(requestUri, body, ct).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();
        }
Ejemplo n.º 3
0
        /// <inheritdoc cref="IFlightSection.PostReturnAsync(long, FlightDto, CancellationToken)"/>
        public async Task PostReturnAsync(long id, FlightDto dto, CancellationToken ct = default)
        {
            var requestUri = Endpoint.AppendPathSegments(id, "returns");
            var body       = new StringContent(JsonSerializer.Serialize(dto), Encoding.UTF8, MediaTypeNames.Application.Json);

            using var response = await HttpClient.PostAsync(requestUri, body, ct).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();
        }
Ejemplo n.º 4
0
        /// <inheritdoc cref="IFlightSection.SetPriorityAsync(long, long, int, CancellationToken)"/>
        public async Task SetPriorityAsync(long id, long returnFlightId, int priority, CancellationToken ct = default)
        {
            var requestUri = Endpoint.AppendPathSegments(id, "returns", returnFlightId, "priority");
            var body       = new StringContent(JsonSerializer.Serialize(priority), Encoding.UTF8, MediaTypeNames.Application.Json);

            using var response = await HttpClient.PatchAsync(requestUri, body, ct).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();
        }
Ejemplo n.º 5
0
        /// <inheritdoc cref="IFlightSection.GetReturnAsync(long, long, CancellationToken)"/>
        public async Task <FlightDto> GetReturnAsync(long id, long returnFlightId, CancellationToken ct = default)
        {
            var requestUri = Endpoint.AppendPathSegments(id, "returns", returnFlightId);

            using var response = await HttpClient.GetAsync(requestUri, ct).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();
            var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            return(JsonSerializer.Deserialize <FlightDto>(content, Options));
        }