Még csak lépések vannak ...
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Json;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.MAUI.DataLayer;
|
||||
using WorkFlowCheck.MAUI.Services.Interfaces;
|
||||
@@ -14,14 +11,45 @@ namespace WorkFlowCheck.MAUI.Services
|
||||
public class CheckListService : BaseService, ICheckListService
|
||||
{
|
||||
private readonly IUserService _userService;
|
||||
public CheckListService(HttpClient httpClient, IConfiguration configuration, AppDbContext dbContext, IMapper mapper, IUserService userService ) : base(httpClient, configuration, dbContext, mapper)
|
||||
public CheckListService(HttpClient httpClient, IConfiguration configuration, AppDbContext dbContext, IMapper mapper, IUserService userService) : base(httpClient, configuration, dbContext, mapper)
|
||||
{
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
public async Task StartNew(UserDTO userDTO)
|
||||
public async Task<ApiResponseDTO<CheckListHeaderDTO>> StartNew(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
// Az API végpont meghatározása
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/checklist/startnew";
|
||||
|
||||
// HTTP POST kérés küldése
|
||||
ApiRequestDTO<CheckListTemplateHeaderDTO> request = new ApiRequestDTO<CheckListTemplateHeaderDTO>();
|
||||
request.UserDTO = _userService.GetCurrentUser();
|
||||
request.Data = checkListTemplateHeaderDTO;
|
||||
|
||||
|
||||
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, request))
|
||||
{
|
||||
httpResponseMessage.EnsureSuccessStatusCode();
|
||||
|
||||
var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||
var response = JsonConvert.DeserializeObject<ApiResponseDTO<CheckListHeaderDTO>>(jsonString);
|
||||
|
||||
return response ?? new ApiResponseDTO<CheckListHeaderDTO>
|
||||
{
|
||||
IsSuccess = false,
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Hiba visszaadása
|
||||
return new ApiResponseDTO<CheckListHeaderDTO>
|
||||
{
|
||||
IsSuccess = false
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user