public static async Task <bool> AddToFlow(FlowSubject flowSubject) { string fSubjString = JsonConvert.SerializeObject(flowSubject); var client = new RestClient("http://eljournal.ddns.net/api/Subjects/flow"); var request = new RestRequest(Method.POST); request.AddHeader("Cache-Control", "no-cache"); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Authorization", "38A1903A-622D-4201-BC6C-25E23D805771"); request.AddParameter("undefined", fSubjString, ParameterType.RequestBody); var cancellationTokenSource = new CancellationTokenSource(); IRestResponse restResponse = await client.ExecuteTaskAsync(request, cancellationTokenSource.Token); //ассинхронный метод if (restResponse.IsSuccessful) { return(true); } else { return(false); } }
public static async Task <FlowSubject> GetInstanceAsync(string id) { if (string.IsNullOrEmpty(id)) { return(null); } var client = new RestClient(string.Format("http://eljournal.ddns.net/api/Subjects/flow/{0}", id)); var request = new RestRequest(Method.GET); IRestResponse restResponse = client.Execute(request); if (restResponse.IsSuccessful) { Response result = JsonConvert.DeserializeObject <Response>(restResponse.Content); FlowSubject subject = result.Data.ToObject <FlowSubject>(); return(subject); } else { return(null); } }