/// <summary> /// Posts an order data transfer object to queue. /// </summary> /// <param name="orderDto"> /// The order data transfer object. /// </param> /// <param name="serviceBusNamespace"> /// The service bus namespace. /// </param> /// <param name="sasKeyName"> /// The shared access signature key name. /// </param> /// <param name="sasKey"> /// The shared access signature key. /// </param> /// <param name="queue"> /// The queue. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> public static async Task <HttpResponseMessage> PostOrderDtoToQueue(AzureHeartBeat orderDto, string serviceBusNamespace, string sasKeyName, string sasKey, string queue) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseServiceBusAddress); client.DefaultRequestHeaders.Accept.Clear(); var token = GetSasToken(sasKeyName, sasKey); client.DefaultRequestHeaders.Add("Authorization", token); HttpContent content = new StringContent(JsonConvert.SerializeObject(orderDto), Encoding.UTF8); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var path = BaseServiceBusAddress + queue + "/messages"; return(await client.PostAsync(path, content)); } }
/// <summary> /// Saves the heart beat. /// </summary> /// <returns>true, if operation succeeded. false, if operation failed.</returns> /// <param name="request">Request is the heartbeat</param> public async Task <bool> SaveHeartBeat(AzureHeartBeat request) { return(await Task.FromResult(true)); }