public async Task <Dictionary <string, object> > HandleRequest(ExternalTask externalTask, Dictionary <string, object> resultVariables) { SendEmailDescriptor content = new SendEmailDescriptor() { to = new MailAddress() { Email = externalTask.Variables["email_to"].Value.ToString(), Name = externalTask.Variables["name_to"].Value.ToString() }, from = new MailAddress() { Email = externalTask.Variables["email_from"].Value.ToString(), Name = externalTask.Variables["name_from"].Value.ToString() }, subject = externalTask.Variables["subject"].Value.ToString(), htmlContent = externalTask.Variables["htmlContent"].Value.ToString(), textContent = externalTask.Variables["textContent"].Value.ToString() }; StringContent stringContent = new StringContent(JsonConvert.SerializeObject(content), System.Text.Encoding.UTF8, "application/json"); HandleRequestContext a = new HandleRequestContext(_httpClient); resultVariables = await a.Post(resultVariables, "/email", stringContent); return(resultVariables); }
public async Task <Dictionary <string, object> > HandleRequest(ExternalTask externalTask, Dictionary <string, object> resultVariables) { string action = externalTask.Variables.ContainsKey("Action") ? externalTask.Variables["Action"].Value.ToString() : null; string table = externalTask.Variables.ContainsKey("Table") ? externalTask.Variables["Table"].Value.ToString() : null; string primaryKey = externalTask.Variables.ContainsKey("PrimaryKey") ? externalTask.Variables["PrimaryKey"].Value.ToString() : null; string data = externalTask.Variables.ContainsKey("Data") ? externalTask.Variables["Data"].Value.ToString() : null; DataDescriptor descriptor = new DataDescriptor() { Table_Name = table, PrimaryKey = primaryKey, Data = data != null?JsonConvert.DeserializeObject <IDictionary <string, JToken> >(data) : null }; StringContent stringContent = new StringContent(JsonConvert.SerializeObject(descriptor), System.Text.Encoding.UTF8, "application/json"); HttpResponseMessage response = new HttpResponseMessage(); HandleRequestContext a = new HandleRequestContext(_httpClient); switch (action) { case "GET": string result = await a.Get(resultVariables, Postfix + "/" + descriptor.Table_Name + "/" + descriptor.PrimaryKey); resultVariables = JsonConvert.DeserializeObject <Dictionary <string, object> >(result); break; case "POST": resultVariables = await a.Post(resultVariables, Postfix, stringContent); break; case "PUT": resultVariables = await a.Put(resultVariables, Postfix, stringContent); break; } return(resultVariables); }