diff --git a/src/Plugin.NFC/Plugin.NFC.csproj b/src/Plugin.NFC/Plugin.NFC.csproj index e1f631b..0c629fe 100644 --- a/src/Plugin.NFC/Plugin.NFC.csproj +++ b/src/Plugin.NFC/Plugin.NFC.csproj @@ -2,7 +2,8 @@ - netstandard1.0;netstandard2.0;Xamarin.iOS10;MonoAndroid10.0;net8.0;net8.0-android;net8.0-ios + + net8.0;net8.0-android;net8.0-ios Plugin.NFC Plugin.NFC diff --git a/src/WorkFlowCheck.API/Controllers/UserController.cs b/src/WorkFlowCheck.API/Controllers/UserController.cs index 3de56b2..5ec0994 100644 --- a/src/WorkFlowCheck.API/Controllers/UserController.cs +++ b/src/WorkFlowCheck.API/Controllers/UserController.cs @@ -9,9 +9,15 @@ namespace WorkFlowCheck.API.Controllers public class UserController : ControllerBase { [HttpGet] - public ActionResult Get() + public async Task> Get() { - return new ResponseDTO { Message = "Success" }; + var userDTO = new UserDTO() { Id = 1, Email = "email", Name = "Name" }; + var retVal = new ApiResponseDTO() + { + IsSuccess = true, + Data = userDTO + }; + return retVal; } } } diff --git a/src/WorkFlowCheck.API/Program.cs b/src/WorkFlowCheck.API/Program.cs index a2e9be8..8472790 100644 --- a/src/WorkFlowCheck.API/Program.cs +++ b/src/WorkFlowCheck.API/Program.cs @@ -4,6 +4,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using WorkFlowCheck.API; using WorkFlowCheck.DL; +using Microsoft.AspNetCore.Mvc; var builder = WebApplication.CreateBuilder(args); @@ -45,12 +46,13 @@ builder.Services.AddSwaggerGen(c => }); }); -// Szolgáltatások hozzáadása -builder.Services.AddControllers().AddJsonOptions(options => -{ - options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; - options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; -}); ; +builder.Services.AddControllers() + .AddNewtonsoftJson(options => + { + // Itt konfigurálhatod az egyedi beállításokat + options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore; + options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; + }); var app = builder.Build(); // Swagger middleware diff --git a/src/WorkFlowCheck.API/WorkFlowCheck.API.csproj b/src/WorkFlowCheck.API/WorkFlowCheck.API.csproj index 625b164..68a71bf 100644 --- a/src/WorkFlowCheck.API/WorkFlowCheck.API.csproj +++ b/src/WorkFlowCheck.API/WorkFlowCheck.API.csproj @@ -14,6 +14,7 @@ + diff --git a/src/WorkFlowCheck.BL/DTO/ApiResponseDTO.cs b/src/WorkFlowCheck.BL/DTO/ApiResponseDTO.cs new file mode 100644 index 0000000..d5d4176 --- /dev/null +++ b/src/WorkFlowCheck.BL/DTO/ApiResponseDTO.cs @@ -0,0 +1,39 @@ +using System.Text.Json.Serialization; + +namespace WorkFlowCheck.BL.DTO +{ + public class ApiResponseBaseDTO + { + public bool IsSuccess { get; set; } + public IEnumerable Errors { get; set; } + public bool HandleError { get; set; } + public string Error + { + get + { + if (Errors == null || Errors.Count() == 0) return string.Empty; + return string.Join(';', Errors); + } + } + } + + public class ApiResponseDTO : ApiResponseBaseDTO + { + public object Data { get; set; } + } + + public interface IApiResponseDTO + { + + } + + public class ApiResponseDTO : ApiResponseBaseDTO, IApiResponseDTO + { + public T Data { get; set; } + } + public class ApiResponseListDTO : ApiResponseBaseDTO + { + public T[] Data { get; set; } + public int Total { get; set; } + } +} diff --git a/src/WorkFlowCheck.BL/DTO/ResponseDTO.cs b/src/WorkFlowCheck.BL/DTO/ResponseDTO.cs deleted file mode 100644 index 1c81727..0000000 --- a/src/WorkFlowCheck.BL/DTO/ResponseDTO.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Text.Json.Serialization; - -namespace WorkFlowCheck.BL.DTO -{ - [JsonSerializable(typeof(ResponseDTO))] - public class ResponseDTO - { - public string Message { get; set; } = null!; - } -} diff --git a/src/WorkFlowCheck.BL/DTO/UserDTO.cs b/src/WorkFlowCheck.BL/DTO/UserDTO.cs new file mode 100644 index 0000000..2ebece0 --- /dev/null +++ b/src/WorkFlowCheck.BL/DTO/UserDTO.cs @@ -0,0 +1,9 @@ +namespace WorkFlowCheck.BL.DTO +{ + public class UserDTO + { + public int Id { get; set; } + public string Name { get; set; } = null!; + public string Email { get; set; } = null!; + } +} diff --git a/src/WorkFlowCheck.MAUI/Services/UserService.cs b/src/WorkFlowCheck.MAUI/Services/UserService.cs new file mode 100644 index 0000000..51b6466 --- /dev/null +++ b/src/WorkFlowCheck.MAUI/Services/UserService.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http.Json; +using System.Text; +using System.Threading.Tasks; +using WorkFlowCheck.BL.DTO; + +namespace WorkFlowCheck.MAUI.Services +{ + public class UserService + { + private readonly HttpClient _httpClient; + public UserService(HttpClient httpClient) + { + _httpClient = httpClient; + + // Alapértelmezett fejléc beállítása az API-kulccsal + _httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "YOUR_API_KEY"); + // Ha egyéni fejlécet használsz: + // _httpClient.DefaultRequestHeaders.Add("X-Api-Key", "YOUR_API_KEY"); + } + public async Task> GetUserAsync() + { + try + { + // Az API végpont meghatározása + string endpoint = "api/user"; + + // HTTP GET kérés küldése + var response = await _httpClient.GetFromJsonAsync>(endpoint); + + return response ?? new ApiResponseDTO + { + IsSuccess = false, + }; + } + catch (Exception ex) + { + // Hiba visszaadása + return new ApiResponseDTO + { + IsSuccess = false + }; + } + } + } +} diff --git a/src/WorkFlowCheck.MAUI/WorkFlowCheck.MAUI.csproj b/src/WorkFlowCheck.MAUI/WorkFlowCheck.MAUI.csproj index 8561f7f..0145488 100644 --- a/src/WorkFlowCheck.MAUI/WorkFlowCheck.MAUI.csproj +++ b/src/WorkFlowCheck.MAUI/WorkFlowCheck.MAUI.csproj @@ -57,6 +57,8 @@ + + @@ -64,6 +66,7 @@ +