1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using DynamicExpresso;
- using Microsoft.AspNetCore.Components.Authorization;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net.Http;
- using System.Net.Http.Json;
- using System.Threading.Tasks;
- using wispro.sp.entity;
- using wispro.sp.share;
- using wispro.sp.web.Auth;
- namespace wispro.sp.web.Services
- {
- public class AppealTypeService
- {
- private readonly HttpClient _httpClient;
- private readonly JwtAuthenticationStateProvider _jwt;
- private List<AppealType> AppealTypes;
- public AppealTypeService(HttpClient httpClient, AuthenticationStateProvider jwt)
- {
- _httpClient = httpClient;
- _jwt = (JwtAuthenticationStateProvider)jwt;
-
- }
- public async Task<List<AppealType>> GetItems()
- {
- if (AppealTypes == null)
- {
- AppealTypes = await _httpClient.GetFromJsonAsync<List<AppealType>>($"http://localhost:39476/api/Appeal/GetAppealTypes");
-
- }
- return AppealTypes;
- }
- public List<AppealType> GetItems(PerformanceItem item)
- {
-
- List<AppealType> retList = new List<AppealType>();
- foreach (var at in AppealTypes)
- {
- 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);
- if (result)
- {
- retList.Add(at);
- }
- }
- else
- {
- retList.Add(at);
- }
- }
- return retList;
- }
- public async Task<AppealType> GetItem(int appealTypeId)
- {
- if (AppealTypes == null)
- {
- AppealTypes = await _httpClient.GetFromJsonAsync<List<AppealType>>($"http://localhost:39476/api/Appeal/GetAppealTypes");
- }
- var retData = AppealTypes.Where<AppealType>(ap => ap.Id == appealTypeId).FirstOrDefault();
- return retData;
- }
- public async Task<List<InputField>> GetInputFields(int appealTypeId,int State)
- {
- var data = await _httpClient.GetFromJsonAsync<List<InputField>>($"http://localhost:39476/api/Appeal/GetInputField?appealTypeId={appealTypeId}&state={State}");
- return data;
- }
- }
- }
|