46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using System.Globalization;
|
|
using UGQApiServer.Converter;
|
|
using UGQApiServer.Models;
|
|
using UGQDataAccess;
|
|
using ServerCommon;
|
|
using ServerCommon.UGQ.Models;
|
|
using UGQApiServer.UGQData;
|
|
|
|
namespace UGQApiServer;
|
|
|
|
public static class ApiResponseFactory
|
|
{
|
|
public static ApiErrorResponse error(ServerErrorCode errorCode)
|
|
{
|
|
LangEnum langEnum = Culture.ToLangEnum(CultureInfo.CurrentCulture.Name);
|
|
|
|
var textId = errorCode.ToString().Replace("Ugq", "UGQ_Error_");
|
|
var message = UGQDataHelper.getText(langEnum, textId);
|
|
|
|
return new ApiErrorResponse
|
|
{
|
|
ErrorCode = (int)errorCode,
|
|
ErrorMessage = message ?? errorCode.ToString(),
|
|
};
|
|
}
|
|
|
|
|
|
public static ValidationErrorResponse validationError(ServerErrorCode errorCode, List<string> errors)
|
|
{
|
|
LangEnum langEnum = Culture.ToLangEnum(CultureInfo.CurrentCulture.Name);
|
|
|
|
var textId = errorCode.ToString().Replace("Ugq", "UGQ_Error_");
|
|
var message = UGQDataHelper.getText(langEnum, textId);
|
|
|
|
return new ValidationErrorResponse
|
|
{
|
|
ErrorCode = (int)errorCode,
|
|
ErrorMessage = message ?? errorCode.ToString(),
|
|
ValidationErrorMessages = errors
|
|
};
|
|
}
|
|
|
|
|
|
|
|
}
|