|
@@ -16,11 +16,11 @@ namespace wispro.sp.web.Services
|
|
|
{
|
|
|
public class AppealTypeService
|
|
|
{
|
|
|
- private readonly HttpClient _httpClient;
|
|
|
+ private readonly IHttpService _httpClient;
|
|
|
private readonly JwtAuthenticationStateProvider _jwt;
|
|
|
private List<AppealType> AppealTypes;
|
|
|
|
|
|
- public AppealTypeService(HttpClient httpClient, AuthenticationStateProvider jwt)
|
|
|
+ public AppealTypeService(IHttpService httpClient, AuthenticationStateProvider jwt)
|
|
|
{
|
|
|
_httpClient = httpClient;
|
|
|
_jwt = (JwtAuthenticationStateProvider)jwt;
|
|
@@ -30,13 +30,13 @@ namespace wispro.sp.web.Services
|
|
|
|
|
|
public async Task<AppealRecord> getAppealRecord(int appealRecordId)
|
|
|
{
|
|
|
- var data = await _httpClient.GetFromJsonAsync<AppealRecord>($"http://localhost:39476/api/Appeal/GetAppealRecord?Id={appealRecordId}");
|
|
|
+ var data = await _httpClient.Get<AppealRecord>($"Appeal/GetAppealRecord?Id={appealRecordId}");
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
public async Task<List<InputFieldValue>> GetInputFieldValues(int id, int state)
|
|
|
{
|
|
|
- var data = await _httpClient.GetFromJsonAsync<List<InputFieldValue>>($"http://localhost:39476/api/Appeal/GetInputFieldValues?Id={id}&state={state}");
|
|
|
+ var data = await _httpClient.Get<List<InputFieldValue>>($"Appeal/GetInputFieldValues?Id={id}&state={state}");
|
|
|
return data;
|
|
|
}
|
|
|
|
|
@@ -44,22 +44,25 @@ namespace wispro.sp.web.Services
|
|
|
{
|
|
|
if (AppealTypes == null)
|
|
|
{
|
|
|
- AppealTypes = await _httpClient.GetFromJsonAsync<List<AppealType>>($"http://localhost:39476/api/Appeal/GetAppealTypes");
|
|
|
+ AppealTypes = await _httpClient.Get<List<AppealType>>($"Appeal/GetAppealTypes");
|
|
|
|
|
|
}
|
|
|
return AppealTypes;
|
|
|
}
|
|
|
|
|
|
+ public List<AppealType> GetItems(int Type)
|
|
|
+ {
|
|
|
+ return AppealTypes.Where<AppealType>(at => at.Type == Type).ToList();
|
|
|
+ }
|
|
|
public List<AppealType> GetItems(PerformanceItem item)
|
|
|
{
|
|
|
List<AppealType> retList = new List<AppealType>();
|
|
|
|
|
|
- foreach (var at in AppealTypes)
|
|
|
+ foreach (var at in GetItems(0))
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(at.CanDoExpress))
|
|
|
{
|
|
|
var interpreter = new Interpreter();
|
|
|
- //Console.WriteLine(at.CanDoExpress);
|
|
|
Func<PerformanceItem, bool> func = interpreter.ParseAsDelegate<Func<PerformanceItem, bool>>(at.CanDoExpress, "p");
|
|
|
bool result = func.Invoke(item);
|
|
|
|
|
@@ -79,7 +82,7 @@ namespace wispro.sp.web.Services
|
|
|
|
|
|
public async Task<List<AppealRecord>> GetUserAppeals(int? userid)
|
|
|
{
|
|
|
- var data = await _httpClient.GetFromJsonAsync<List<AppealRecord>>($"http://localhost:39476/api/Appeal/GetAppealRecords?userId={userid}");
|
|
|
+ var data = await _httpClient.Get<List<AppealRecord>>($"Appeal/GetAppealRecords?userId={userid}");
|
|
|
return data;
|
|
|
}
|
|
|
|
|
@@ -87,7 +90,7 @@ namespace wispro.sp.web.Services
|
|
|
{
|
|
|
if (AppealTypes == null)
|
|
|
{
|
|
|
- AppealTypes = await _httpClient.GetFromJsonAsync<List<AppealType>>($"http://localhost:39476/api/Appeal/GetAppealTypes");
|
|
|
+ AppealTypes = await _httpClient.Get<List<AppealType>>($"Appeal/GetAppealTypes");
|
|
|
}
|
|
|
|
|
|
var retData = AppealTypes.Where<AppealType>(ap => ap.Id == appealTypeId).FirstOrDefault();
|
|
@@ -97,14 +100,13 @@ namespace wispro.sp.web.Services
|
|
|
|
|
|
public async Task<List<InputField>> GetInputFields(int appealTypeId,int State)
|
|
|
{
|
|
|
- Console.WriteLine($"begin GetInputFields: appealTypeId={appealTypeId};State={State}");
|
|
|
- var data = await _httpClient.GetFromJsonAsync<List<InputField>>($"http://localhost:39476/api/Appeal/GetInputField?appealTypeId={appealTypeId}&state={State}");
|
|
|
+ var data = await _httpClient.Get<List<InputField>>($"Appeal/GetInputField?appealTypeId={appealTypeId}&state={State}");
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
public async Task<List<AttachFile>> GetAppealRecordAttachFiles(int appealRecordId)
|
|
|
{
|
|
|
- var data = await _httpClient.GetFromJsonAsync<List<AttachFile>>($"http://localhost:39476/api/Appeal/GetAppealRecordAttachFiles?appealRecordId={appealRecordId}");
|
|
|
+ var data = await _httpClient.Get<List<AttachFile>>($"Appeal/GetAppealRecordAttachFiles?appealRecordId={appealRecordId}");
|
|
|
return data;
|
|
|
}
|
|
|
|
|
@@ -120,7 +122,7 @@ namespace wispro.sp.web.Services
|
|
|
attachFiles.Add(atfile);
|
|
|
}
|
|
|
|
|
|
- string strUrl = $"http://localhost:39476/api/Appeal/CreateAppeal?ItemId={model.Item.Id}&typeid={model.AppealType.Id}&reviewerId={model.AppealRecord.ReviewerId}";
|
|
|
+ string strUrl = $"Appeal/CreateAppeal?ItemId={model.Item.Id}&typeid={model.AppealType.Id}&reviewerId={model.AppealRecord.ReviewerId}";
|
|
|
AppealObject appealObject = new AppealObject();
|
|
|
appealObject.attachFiles = attachFiles;
|
|
|
appealObject.inputFieldValues = model.inputFieldValues;
|
|
@@ -129,15 +131,29 @@ namespace wispro.sp.web.Services
|
|
|
fValue.InputField = null;
|
|
|
}
|
|
|
|
|
|
- var data = await _httpClient.PostAsJsonAsync<AppealObject>(strUrl, appealObject);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var data = await _httpClient.Post<ApiSaveResponse>(strUrl, appealObject);
|
|
|
+
|
|
|
+ if (!data.Success)
|
|
|
+ {
|
|
|
+ if (!data.Success)
|
|
|
+ {
|
|
|
+ throw new ApplicationException(data.ErrorMessage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex)
|
|
|
+ {
|
|
|
+ throw ex;
|
|
|
+ }
|
|
|
|
|
|
- Console.WriteLine(JsonSerializer.Serialize(data));
|
|
|
}
|
|
|
|
|
|
public async Task ReviewerAppeal(ReviewerAppealModel model)
|
|
|
{
|
|
|
|
|
|
- string strUrl = $"http://localhost:39476/api/Appeal/ReviewerAppeal?appealRecordId={model.AppealRecord.Id}";
|
|
|
+ string strUrl = $"Appeal/ReviewerAppeal?appealRecordId={model.AppealRecord.Id}";
|
|
|
AppealObject appealObject = new AppealObject();
|
|
|
appealObject.inputFieldValues = model.inputFieldValues;
|
|
|
|
|
@@ -146,13 +162,26 @@ namespace wispro.sp.web.Services
|
|
|
fValue.InputField = null;
|
|
|
}
|
|
|
|
|
|
- var data = await _httpClient.PostAsJsonAsync<AppealObject>(strUrl, appealObject);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var data = await _httpClient.Post<ApiSaveResponse>(strUrl, appealObject);
|
|
|
|
|
|
- if (!data.IsSuccessStatusCode)
|
|
|
+ if (!data.Success)
|
|
|
+ {
|
|
|
+ throw new ApplicationException(data.ErrorMessage);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ catch(Exception ex)
|
|
|
{
|
|
|
- string strContent = await data.Content.ReadAsStringAsync();
|
|
|
- throw new Exception(strContent);
|
|
|
+ throw ex;
|
|
|
}
|
|
|
+
|
|
|
+ //if (!data.IsSuccessStatusCode)
|
|
|
+ //{
|
|
|
+ // string strContent = await data.Content.ReadAsStringAsync();
|
|
|
+ // throw new Exception(strContent);
|
|
|
+ //}
|
|
|
}
|
|
|
|
|
|
|