| @code { | @code { | ||||
| [Parameter] | |||||
| public string FromRoute { get; set; } | |||||
| [Parameter] | |||||
| public string FromRoute { get; set; } | |||||
| private UserData Account = new(); | private UserData Account = new(); | ||||
| } | } | ||||
| private void Next() { | private void Next() { | ||||
| UserDataProvider.mapReport(ReportDataProvider.Report, Account); | |||||
| if ("Found".Equals(FromRoute)) { | if ("Found".Equals(FromRoute)) { | ||||
| UserDataProvider.mapReport(ReportDataProvider.Report, Account); | |||||
| NavigationManager.NavigateTo("fundvelo/conclusion_found"); | NavigationManager.NavigateTo("fundvelo/conclusion_found"); | ||||
| } else { | } else { | ||||
| UserDataProvider.mapMissingReport(ReportDataProvider.GetMissingReport(), Account); | |||||
| NavigationManager.NavigateTo("fundvelo/conclusion_missing"); | NavigationManager.NavigateTo("fundvelo/conclusion_missing"); | ||||
| } | } | ||||
| } | } |
| base.OnInitialized(); | base.OnInitialized(); | ||||
| PageHistoryManager.AddPageToHistory(NavigationManager.Uri); | PageHistoryManager.AddPageToHistory(NavigationManager.Uri); | ||||
| try { | try { | ||||
| response = await ILFBicycleRest.SendFoundReport(ReportDataProvider.GetFoundReport()); | |||||
| response = await ILFBicycleRest.SendFoundReport(ReportDataProvider.Report); | |||||
| responseOk = System.Net.HttpStatusCode.OK == response.StatusCode ? true : false; | responseOk = System.Net.HttpStatusCode.OK == response.StatusCode ? true : false; | ||||
| } catch (HttpRequestException ex) { | } catch (HttpRequestException ex) { | ||||
| response = new(i18n.GetString("FoundBike"), new string[] { ex.Message }); | response = new(i18n.GetString("FoundBike"), new string[] { ex.Message }); |
| @page "/fundvelo/conclusion_missing" | @page "/fundvelo/conclusion_missing" | ||||
| @using cwebplusApp.Shared.Services; | @using cwebplusApp.Shared.Services; | ||||
| @using cwebplusApp.Shared.Models; | |||||
| @inject NavigationManager NavigationManager; | @inject NavigationManager NavigationManager; | ||||
| @inject IStringLocalizer<Resources> i18n; | @inject IStringLocalizer<Resources> i18n; | ||||
| @inject PageHistoryManager PageHistoryManager; | @inject PageHistoryManager PageHistoryManager; | ||||
| @inject ReportDataProvider ReportDataProvider; | @inject ReportDataProvider ReportDataProvider; | ||||
| @inject ILFBicycleRest ILFBicycleRest; | @inject ILFBicycleRest ILFBicycleRest; | ||||
| @inject Toaster Toaster; | |||||
| @inject AppState AppState; | |||||
| <div class="row px-3 h-100"> | <div class="row px-3 h-100"> | ||||
| <div class="row no-gutters align-items-start justify-content-center w-100"> | <div class="row no-gutters align-items-start justify-content-center w-100"> | ||||
| <MatHeadline4 Style="font-family:Ubuntu;padding-top:1em">@i18n["Info"]</MatHeadline4> | <MatHeadline4 Style="font-family:Ubuntu;padding-top:1em">@i18n["Info"]</MatHeadline4> | ||||
| </div> | </div> | ||||
| <div class="row no-gutters align-items-start justify-content-center w-100"> | <div class="row no-gutters align-items-start justify-content-center w-100"> | ||||
| <MatHeadline6 Style="font-family:Ubuntu">@i18n["FinishedTextMissing"]</MatHeadline6> | |||||
| @if (running) { | |||||
| <div style="width:48px;margin:0 auto;"> | |||||
| <MatProgressCircle Indeterminate="true" Size="MatProgressCircleSize.Large" /> | |||||
| </div> | |||||
| <div class="w-100" style="text-align:center;"> | |||||
| <h6 style="font-style:italic;padding-bottom:1em">@i18n["Info.Report.Transmitting"]</h6> | |||||
| </div> | |||||
| } else { | |||||
| if (responseOk) { | |||||
| <MatHeadline6 Style="font-family:Ubuntu">@i18n["FinishedTextMissing"]</MatHeadline6> | |||||
| } | |||||
| } | |||||
| </div> | </div> | ||||
| <div class="row no-gutters align-items-end justify-content-center w-100" style="padding-bottom:2em;padding-top:2em"> | <div class="row no-gutters align-items-end justify-content-center w-100" style="padding-bottom:2em;padding-top:2em"> | ||||
| <div class="col w-100 text-center"> | <div class="col w-100 text-center"> | ||||
| @code { | @code { | ||||
| protected override void OnInitialized() { | |||||
| private bool responseOk = false; | |||||
| private bool running = true; | |||||
| ReportResponse response; | |||||
| protected async override void OnInitialized() { | |||||
| base.OnInitialized(); | base.OnInitialized(); | ||||
| PageHistoryManager.AddPageToHistory(NavigationManager.Uri); | PageHistoryManager.AddPageToHistory(NavigationManager.Uri); | ||||
| ILFBicycleRest.SendMissingReport(ReportDataProvider.GetMissingReport()); | |||||
| try { | |||||
| response = await ILFBicycleRest.SendMissingReport(ReportDataProvider.Report); | |||||
| responseOk = System.Net.HttpStatusCode.OK == response.StatusCode ? true : false; | |||||
| } catch (HttpRequestException ex) { | |||||
| response = new(i18n.GetString("MissingBike"), new string[] { ex.Message }); | |||||
| responseOk = false; | |||||
| } | |||||
| running = false; | |||||
| if (responseOk) { | |||||
| Toaster.ShowSuccess(i18n.GetString("MissingBike"), response.Message); | |||||
| PageHistoryManager.Reset(); | |||||
| } else { | |||||
| Toaster.ShowError(response.Message, response.GetDataAsFormattedList()); | |||||
| } | |||||
| StateHasChanged(); | |||||
| AppState.NotifyChanged(); | |||||
| } | } | ||||
| private void Finished() { | private void Finished() { |
| public string NeueMarke { get; set; } | public string NeueMarke { get; set; } | ||||
| public string Zusatz { get; set; } | public string Zusatz { get; set; } | ||||
| public string Postfach { get; set; } | public string Postfach { get; set; } | ||||
| public int SuchDienstId { get; set; } | |||||
| public int? SuchDienstId { get; set; } | |||||
| public string SuchDienstNr { get; set; } | public string SuchDienstNr { get; set; } | ||||
| Task<List<Brand>> GetBrands(); | Task<List<Brand>> GetBrands(); | ||||
| Task<ReportResponse> SendFoundReport(FoundReport report); | |||||
| Task<ReportResponse> SendFoundReport(Report report); | |||||
| Task<ReportResponse> SendMissingReport(MissingReport report); | |||||
| Task<ReportResponse> SendMissingReport(Report report); | |||||
| } | } | ||||
| } | } |
| throw new HttpRequestException("HTTP client not initialized!"); | throw new HttpRequestException("HTTP client not initialized!"); | ||||
| } | } | ||||
| public async Task<ReportResponse> SendFoundReport(FoundReport report) { | |||||
| public async Task<ReportResponse> SendFoundReport(Report report) { | |||||
| string subResourceUrl = Configuration.GetValue<string>("subresource_url_foundreport"); | |||||
| return await SendReport(report, subResourceUrl); | |||||
| } | |||||
| public async Task<ReportResponse> SendMissingReport(Report report) { | |||||
| string subResourceUrl = Configuration.GetValue<string>("subresource_url_missingreport"); | |||||
| return await SendReport(report, subResourceUrl); | |||||
| } | |||||
| protected async Task<ReportResponse> SendReport(Report report, string subResourceUrl) { | |||||
| if (httpClient != null) { | if (httpClient != null) { | ||||
| string subResourceUrl = Configuration.GetValue<string>("subresource_url_foundreport"); | |||||
| if (!String.IsNullOrEmpty(subResourceUrl)) { | if (!String.IsNullOrEmpty(subResourceUrl)) { | ||||
| string reportJson = JsonConvert.SerializeObject(report); | string reportJson = JsonConvert.SerializeObject(report); | ||||
| HttpContent content = new StringContent(reportJson, Encoding.UTF8, "application/json"); | HttpContent content = new StringContent(reportJson, Encoding.UTF8, "application/json"); | ||||
| } | } | ||||
| throw new HttpRequestException("HTTP client not initialized!"); | throw new HttpRequestException("HTTP client not initialized!"); | ||||
| } | } | ||||
| public async Task<ReportResponse> SendMissingReport(MissingReport report) { | |||||
| if (httpClient != null) { | |||||
| string subResourceUrl = Configuration.GetValue<string>("subresource_url_missingreport"); | |||||
| if (!String.IsNullOrEmpty(subResourceUrl)) { | |||||
| string reportJson = JsonConvert.SerializeObject(report); | |||||
| HttpContent content = new StringContent(reportJson, Encoding.UTF8, "application/json"); | |||||
| HttpResponseMessage httpResult = await httpClient.PostAsync(string.Format(subResourceUrl, VERSION, CultureInfo.CurrentCulture.TwoLetterISOLanguageName), content); | |||||
| if (httpResult.StatusCode == System.Net.HttpStatusCode.OK) { | |||||
| ReportResponse reponse = JsonConvert.DeserializeObject<ReportResponse>(await httpResult.Content.ReadAsStringAsync()); | |||||
| return reponse; | |||||
| } | |||||
| throw new HttpRequestException("HTTP error " + httpResult.StatusCode); | |||||
| } | |||||
| } | |||||
| throw new HttpRequestException("HTTP client not initialized!"); | |||||
| } | |||||
| } | } | ||||
| } | } |
| report.Nachname = Lastname; | report.Nachname = Lastname; | ||||
| report.Telefon = Phone; | report.Telefon = Phone; | ||||
| } | } | ||||
| public static void mapMissingReport(MissingReport report, UserData userData) { | |||||
| report.Anrede = userData.Salutation; | |||||
| report.Vorname = userData.Firstname; | |||||
| report.Nachname = userData.Lastname; | |||||
| report.Telefon = userData.Phone; | |||||
| report.PersonOrt = userData.City; | |||||
| report.PersonPLZ = userData.Zip; | |||||
| report.PersonStrasse = userData.Address; | |||||
| report.Mobil = userData.Phone; | |||||
| report.Mail = userData.Email; | |||||
| } | |||||
| } | } | ||||
| } | } |