RoleCheckPoint
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.Common.Enums;
|
||||
using WorkFlowCheck.Web.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.Web.Services
|
||||
@@ -200,6 +204,24 @@ namespace WorkFlowCheck.Web.Services
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public List<SelectListItem> GetCheckStatus()
|
||||
{
|
||||
return Enum.GetValues(typeof(CheckStatus))
|
||||
.Cast<CheckStatus>()
|
||||
.Select(e => new SelectListItem
|
||||
{
|
||||
Value = ((int)e).ToString(),
|
||||
Text = GetEnumDisplayName(e)
|
||||
}).ToList();
|
||||
}
|
||||
private string GetEnumDisplayName(Enum enumValue)
|
||||
{
|
||||
return enumValue.GetType()
|
||||
.GetMember(enumValue.ToString())
|
||||
.First()
|
||||
.GetCustomAttribute<DisplayAttribute>()?.Name ?? enumValue.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
|
||||
namespace WorkFlowCheck.Web.Services.Interfaces
|
||||
{
|
||||
@@ -18,5 +19,7 @@ namespace WorkFlowCheck.Web.Services.Interfaces
|
||||
Task<CheckListRowDTO> GetCheckListRow(int id);
|
||||
Task<ApiResponseDTO<CheckListRowDTO>> UpdateCheckListRow(CheckListRowDTO checkListRowDTO);
|
||||
|
||||
List<SelectListItem> GetCheckStatus();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,5 +21,9 @@ namespace WorkFlowCheck.Web.Services.Interfaces
|
||||
Task<RoleCheckListTemplateHeaderDTO> GetRoleCheckListTemplateHeader(int id);
|
||||
Task<List<RoleCheckListTemplateHeaderDTO>> GetAllRoleCheckListTemplates();
|
||||
Task<ApiResponseDTO<RoleCheckListTemplateHeaderDTO>> UpdateRoleCheckListTemplateHeader(RoleCheckListTemplateHeaderDTO roleCheckListTemplateHeaderDTO);
|
||||
|
||||
Task<RoleCheckPointDTO> GetRoleCheckPoint(int id);
|
||||
Task<List<RoleCheckPointDTO>> GetAllRoleCheckPoints();
|
||||
Task<ApiResponseDTO<RoleCheckPointDTO>> UpdateRoleCheckPoint(RoleCheckPointDTO roleCheckPointDTO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,5 +335,76 @@ namespace WorkFlowCheck.Web.Services
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<RoleCheckPointDTO> GetRoleCheckPoint(int id)
|
||||
{
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/user/GetRoleCheckPoint/{id}";
|
||||
var retVal = new RoleCheckPointDTO();
|
||||
try
|
||||
{
|
||||
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<RoleCheckPointDTO>>(endpoint);
|
||||
if (response != null)
|
||||
{
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
return response.Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<RoleCheckPointDTO>> GetAllRoleCheckPoints()
|
||||
{
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/User/GetAllRoleCheckPoints";
|
||||
var retVal = new List<RoleCheckPointDTO>();
|
||||
try
|
||||
{
|
||||
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<List<RoleCheckPointDTO>>>(endpoint);
|
||||
if (response != null)
|
||||
{
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
return response.Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<ApiResponseDTO<RoleCheckPointDTO>> UpdateRoleCheckPoint(RoleCheckPointDTO roleCheckPointDTO)
|
||||
{
|
||||
try
|
||||
{
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/user/UpdateRoleCheckPoint";
|
||||
|
||||
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, roleCheckPointDTO))
|
||||
{
|
||||
httpResponseMessage.EnsureSuccessStatusCode();
|
||||
|
||||
var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||
var response = JsonConvert.DeserializeObject<ApiResponseDTO<RoleCheckPointDTO>>(jsonString);
|
||||
|
||||
return response ?? new ApiResponseDTO<RoleCheckPointDTO>
|
||||
{
|
||||
IsSuccess = false,
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Hiba visszaadása
|
||||
return new ApiResponseDTO<RoleCheckPointDTO>
|
||||
{
|
||||
IsSuccess = false
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user