ProfileService.cs 894 B

123456789101112131415161718192021222324252627282930313233
  1. using System.Net.Http;
  2. using System.Net.Http.Json;
  3. using System.Threading.Tasks;
  4. using wispro.sp.web.Models;
  5. namespace wispro.sp.web.Services
  6. {
  7. public interface IProfileService
  8. {
  9. Task<BasicProfileDataType> GetBasicAsync();
  10. Task<AdvancedProfileData> GetAdvancedAsync();
  11. }
  12. public class ProfileService : IProfileService
  13. {
  14. private readonly HttpClient _httpClient;
  15. public ProfileService(HttpClient httpClient)
  16. {
  17. _httpClient = httpClient;
  18. }
  19. public async Task<BasicProfileDataType> GetBasicAsync()
  20. {
  21. return await _httpClient.GetFromJsonAsync<BasicProfileDataType>("data/basic.json");
  22. }
  23. public async Task<AdvancedProfileData> GetAdvancedAsync()
  24. {
  25. return await _httpClient.GetFromJsonAsync<AdvancedProfileData>("data/advanced.json");
  26. }
  27. }
  28. }