| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using CaritasPWA.Shared.Models;
- using CaritasPWA.Shared.ResourceFiles;
- using Json.Net;
- using Microsoft.Extensions.Localization;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Net.Http;
- using System.Threading.Tasks;
-
- namespace CaritasPWA.Shared.Services {
-
- // REST interface responsible to submit lost or found reports and get the available masterdata.
- public class LFBicycleRest : ILFBicycleRest {
-
- private static readonly string VERSION = "v1";
-
- private readonly IStringLocalizer<Resources> _i18n;
- private readonly HttpClient httpClient;
-
- public LFBicycleRest(IStringLocalizer<Resources> i18n) {
- _i18n = i18n;
- this.httpClient = new HttpClient { BaseAddress = new Uri("https://integrate.dynalias.net:9443/Fundvelo/") };
- }
-
- public async Task<List<ColorItem>> GetColors() {
-
- try {
- HttpResponseMessage httpResult = await httpClient.GetAsync(string.Format("api/{0}/{1}/fundvelo/colors", VERSION, CultureInfo.CurrentCulture.TwoLetterISOLanguageName));
-
- if (httpResult.StatusCode == System.Net.HttpStatusCode.OK) {
- ColorItem[] colors = JsonNet.Deserialize<ColorItem[]>(await httpResult.Content.ReadAsStringAsync());
- return new List<ColorItem>(colors);
- }
- // TODO: show a warning message here
- } catch (Exception ex) {
- // TODO: show a warning message here
- }
- return new List<ColorItem>();
- }
-
- public List<BicycleType> GetBicycleTypes() {
- //return Defaults.GetBicycleTypeDefaults(_i18n);
- return new List<BicycleType>();
- }
-
-
- public List<Brand> GetBrands() {
- //return Defaults.Brands.ToList();
- return new List<Brand>();
- }
-
- }
- }
|