public bool InsertTask(TaskStruct task) { try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(RequestUri.BaseUrl); var content = new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("targetId", task.innerTaskId.ToString()), new KeyValuePair<string, string>("ownerId", task.ownerId.ToString()), new KeyValuePair<string, string>("tags", string.Join(",",task.tags)), new KeyValuePair<string, string>("content", task.content) }); var result = client.PostAsync(RequestUri.InsertTaskRequestUri, content).Result; string resultContent = result.Content.ReadAsStringAsync().Result; return true; } } catch { return false; } }
public bool AlterTask(TaskStruct task) { try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(RequestUri.BaseUrl); var content = new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("innerTaskId", task.innerTaskId.ToString()), new KeyValuePair<string, string>("state", task.state ? "true" : "false"), }); var result = client.PostAsync(RequestUri.AlterTaskRequestUri, content).Result; string resultContent = result.Content.ReadAsStringAsync().Result; return true; } } catch { return false; } }