47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using System.Net.Http.Json;
|
|
using TIAM.Entities.TransferDestinations;
|
|
using TIAMWebApp.Shared.Application.Interfaces;
|
|
using TIAMWebApp.Shared.Application.Models;
|
|
using TIAMWebApp.Shared.Application.Models.ClientSide;
|
|
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
|
|
|
|
namespace TIAMMobileApp.Services
|
|
{
|
|
|
|
public class TransferDataService : ITransferDataService
|
|
{
|
|
private readonly HttpClient http;
|
|
|
|
public TransferDataService(HttpClient http)
|
|
{
|
|
this.http = http;
|
|
}
|
|
|
|
public async Task<bool> CreateTransferDestination(TransferDestinationWizardModel model)
|
|
{
|
|
var url = $"{Setting.BaseUrl}/{APIUrls.CreateTransferDestination}";
|
|
var response = await http.PostAsJsonAsync(url, model);
|
|
return response.IsSuccessStatusCode;
|
|
}
|
|
|
|
/// <summary>
|
|
/// calls the TransferDataAPI to get the list of destinations
|
|
public async Task<TransferDestination[]?> GetDestinationsAsync()
|
|
{
|
|
var url = $"{Setting.BaseUrl}/{APIUrls.GetTransferDestinations}";
|
|
return await http.GetFromJsonAsync<TransferDestination[]>(url);
|
|
}
|
|
|
|
public Task<TransferDestination> GetTransferDestinationbyAddressAsync(string destinationId)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public async Task<TransferDestination?> GetTransferDestinationbyCoordinatesAsync(string destinationId)
|
|
{
|
|
var url = $"{Setting.BaseUrl}/{APIUrls.GetTransferDestinationByCoordinates}";
|
|
return await http.GetFromJsonAsync<TransferDestination>(url);
|
|
}
|
|
}
|
|
}
|