0

Below is my method when I break pointed the method, it reached the queueName local variable and was null there it does not perform the contents of the If.

private void AddToQueue(OrderDetails orderDetails)
{

    CloudStorageAccount storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=example;AccountKey=hidden==;EndpointSuffix=core.windows.net");
    CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
    var queueName = User.Claims.Where(e => e.Type == "jti").FirstOrDefault();
    if (queueName != null)
    {
        CloudQueue queue = queueClient.GetQueueReference(queueName.Value);           
        queue.CreateIfNotExistsAsync();
        var addqueue = queue.AddMessageAsync(new CloudQueueMessage(JsonConvert.SerializeObject(orderDetails)));
        //need to add a variable which will retrieve all orders from the queue.
    }
}
imsome1
  • 1,182
  • 4
  • 22
  • 37
Bmanzr
  • 13
  • 1
  • 8
  • 1
    What's your question? You're currently only stating facts... First impression based on your code: the Claims of the User doesn't have a claim of type `jti` (or at least doesn't contain it at this point in your code). – rickvdbosch Sep 28 '17 at 09:04
  • my apologies I worded it very badly, I fixed the problem I was having I simply needed to reconfigure a few things however I have a new problem in which the queue does not seem to be populated when the code reaches the addqueue variable. – Bmanzr Sep 28 '17 at 09:15
  • The CloudQueue.AddMessageAsync method (that you should `await` by the way! Add `.Wait()` at the end of the `AddMessageAsync` call) does not have a return type: [CloudQueue.AddMessageAsync](https://learn.microsoft.com/en-us/dotnet/api/microsoft.windowsazure.storage.queue.cloudqueue.addmessageasync?view=azurestorage-8.1.3#Microsoft_WindowsAzure_Storage_Queue_CloudQueue_AddMessageAsync_Microsoft_WindowsAzure_Storage_Queue_CloudQueueMessage_) – rickvdbosch Sep 28 '17 at 09:18
  • Tried to do that but all i get is an error every time I try and the wait to the end not sure if im doing it right? `var addqueue = queue.AddMessageAsync(new CloudQueueMessage(JsonConvert.SerializeObject(orderDetails)).Wait());` – Bmanzr Sep 28 '17 at 09:32
  • Your `.Wait()` is on the `new CloudMessage` now... Move it and drop the `addqueue` variable since `AddMessageAsync` doesn't return anything: `queue.AddMessageAsync(new CloudQueueMessage(JsonConvert.SerializeObject(orderDetails))‌​).Wait();` – rickvdbosch Sep 28 '17 at 09:37

0 Answers0