PWA Fundvelo der Caritas.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

LFBicycleRest.cs 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using CaritasPWA.Shared.Models;
  2. using CaritasPWA.Shared.ResourceFiles;
  3. using Json.Net;
  4. using Microsoft.Extensions.Localization;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Globalization;
  8. using System.Net.Http;
  9. using System.Threading.Tasks;
  10. namespace CaritasPWA.Shared.Services {
  11. // REST interface responsible to submit lost or found reports and get the available masterdata.
  12. public class LFBicycleRest : ILFBicycleRest {
  13. private static readonly string VERSION = "v1";
  14. private readonly IStringLocalizer<Resources> _i18n;
  15. private readonly HttpClient httpClient;
  16. public LFBicycleRest(IStringLocalizer<Resources> i18n) {
  17. _i18n = i18n;
  18. this.httpClient = new HttpClient { BaseAddress = new Uri("https://integrate.dynalias.net:9443/Fundvelo/") };
  19. }
  20. public async Task<List<ColorItem>> GetColors() {
  21. try {
  22. HttpResponseMessage httpResult = await httpClient.GetAsync(string.Format("api/{0}/{1}/fundvelo/colors", VERSION, CultureInfo.CurrentCulture.TwoLetterISOLanguageName));
  23. if (httpResult.StatusCode == System.Net.HttpStatusCode.OK) {
  24. ColorItem[] colors = JsonNet.Deserialize<ColorItem[]>(await httpResult.Content.ReadAsStringAsync());
  25. return new List<ColorItem>(colors);
  26. }
  27. // TODO: show a warning message here
  28. } catch (Exception ex) {
  29. // TODO: show a warning message here
  30. }
  31. return new List<ColorItem>();
  32. }
  33. public List<BicycleType> GetBicycleTypes() {
  34. //return Defaults.GetBicycleTypeDefaults(_i18n);
  35. return new List<BicycleType>();
  36. }
  37. public List<Brand> GetBrands() {
  38. //return Defaults.Brands.ToList();
  39. return new List<Brand>();
  40. }
  41. }
  42. }