diff --git a/AutoCatCore/Model/Osago.cs b/AutoCatCore/Model/Osago.cs index 907233c..a025a36 100644 --- a/AutoCatCore/Model/Osago.cs +++ b/AutoCatCore/Model/Osago.cs @@ -2,15 +2,15 @@ { public class Osago { - public double Date { get; set; } - public string Number { get; set; } - public string Vin { get; set; } - public string PlateNumber { get; set; } - public string Name { get; set; } - public string Status { get; set; } - public string Restrictions { get; set; } - public string Insurant { get; set; } - public string Owner { get; set; } - public string UsageRegion { get; set; } + public double? Date { get; set; } + public string? Number { get; set; } + public string? Vin { get; set; } + public string? PlateNumber { get; set; } + public string? Name { get; set; } + public string? Status { get; set; } + public string? Restrictions { get; set; } + public string? Insurant { get; set; } + public string? Owner { get; set; } + public string? UsageRegion { get; set; } } } diff --git a/AutoCatCore/Model/PlateNumber.cs b/AutoCatCore/Model/PlateNumber.cs index af7f596..c875a8f 100644 --- a/AutoCatCore/Model/PlateNumber.cs +++ b/AutoCatCore/Model/PlateNumber.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; - namespace AutoCatCore.Model; -//[CreateFromString(MethodName = "AutoCat.Controls.PlateNumber.ConvertFromString")] public class PlateNumber { private readonly string _number; diff --git a/AutoCatCore/Model/Requests/Credentials.cs b/AutoCatCore/Model/Requests/Credentials.cs deleted file mode 100644 index 5999c63..0000000 --- a/AutoCatCore/Model/Requests/Credentials.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AutoCat.Model.Requests -{ - class Credentials - { - public string Email { get; set; } - public string Password { get; set; } - } -} diff --git a/AutoCatCore/Model/Requests/PagedResponse.cs b/AutoCatCore/Model/Requests/PagedResponse.cs index 5cca148..d1d3b92 100644 --- a/AutoCatCore/Model/Requests/PagedResponse.cs +++ b/AutoCatCore/Model/Requests/PagedResponse.cs @@ -1,13 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Text; +namespace AutoCatCore.Model.Requests; -namespace AutoCatCore.Model.Requests +public class PagedResponse(int count, string pageToken, List items) { - public class PagedResponse - { - public int? Count { get; set; } - public string PageToken { get; set; } - public List Items { get; set; } - } + public int Count { get; set; } = count; + public string PageToken { get; set; } = pageToken; + public List Items { get; set; } = items; } diff --git a/AutoCatCore/Services/Api/ApiService.cs b/AutoCatCore/Services/Api/ApiService.cs index 23a8c0e..47f4338 100644 --- a/AutoCatCore/Services/Api/ApiService.cs +++ b/AutoCatCore/Services/Api/ApiService.cs @@ -1,7 +1,6 @@ using System.Net.Http.Json; using System.Text; using System.Text.Json; -using AutoCat.Model.Requests; using AutoCatCore.Model; using AutoCatCore.Model.Requests; using AutoCatCore.Services.Storage; @@ -47,12 +46,7 @@ public class ApiService : IApiService public async Task Login(string email, string password) { - var credentials = new Credentials { Email = email, Password = password }; - var json = JsonSerializer.Serialize(credentials, new JsonSerializerOptions { - PropertyNamingPolicy = JsonNamingPolicy.CamelCase - }); - var content = new StringContent(json, Encoding.UTF8, "application/json"); - var response = await _httpClient.PostAsync("user/login", content); + var response = await _httpClient.PostAsJsonAsync("user/login", new { email, password }); var result = await GetDataOrThrow(response); SetAccessToken(result.Token); return result;