using ProjectManagementSystem.Common.Logger; using ProjectManagementSystem.Common.Models.Crms; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProjectManagementSystem.Common.Service { public class PmsCustomApi { private static RestApi restApi = new RestApi(); public static WebMgrResponse Get(string apiName, object pars) { try { string url = Common.Function.AppSetting.GetPmsApiCustomUrl(apiName); var res = restApi.Get>(url, pars, null, out string content); //CLog.Instance.SystemLog.WriteDebug($"Get {url}{Environment.NewLine} {JsonConvert.SerializeObject(pars)}{Environment.NewLine} {content}"); return res; } catch (Exception ex) { CLog.Instance.SystemLog.WriteError(ex.Message); return new WebMgrResponse() { message = ex.Message }; } } public static WebMgrResponse Post(string apiName, object body) { try { string url = Common.Function.AppSetting.GetPmsApiCustomUrl(apiName); var res = restApi.Post>(url, null, body, out string content); //CLog.Instance.SystemLog.WriteDebug($"Post {url}{Environment.NewLine} {JsonConvert.SerializeObject(body)}{Environment.NewLine} {content}"); return res; } catch (Exception ex) { CLog.Instance.SystemLog.WriteError(ex.Message); return new WebMgrResponse() { message = ex.Message }; } } } }