Plan1.Controllers.DHBlobController.Index C# (CSharp) Method

Index() public method

public Index ( string id ) : System.Web.Mvc.ActionResult
id string
return System.Web.Mvc.ActionResult
        public ActionResult Index(string id)
        {
            // Retrieve storage account from connection-string
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                CloudConfigurationManager.GetSetting("StorageConnectionString"));

            // Create the blob client
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            // Retrieve reference to a previously created container
            // Permission myPermission = entities.Permissions.FirstOrDefault(p => p.postalAddr == id);
            CloudBlobContainer container = blobClient.GetContainerReference(id);

            // Create the container if it doesn't already exist
            container.CreateIfNotExist();

            List<DHBlob> listBlobs = new List<DHBlob>();

            foreach (var i in container.ListBlobs())
            {
                DHBlob dhBlob = new DHBlob();
                dhBlob.blobURI = i.Uri.ToString();
                listBlobs.Add(dhBlob);
            }

            ViewModelDHBlobs myBlobs = new ViewModelDHBlobs();
            myBlobs.id = id;
            myBlobs.Blobs = listBlobs;
            return View(myBlobs);
        }

Usage Example

 public void DataTest59()
 {
     DHBlobController target = new DHBlobController(); // TODO: Initialize to an appropriate value
     string id = string.Empty; // TODO: Initialize to an appropriate value
     ActionResult expected = null; // TODO: Initialize to an appropriate value
     ActionResult actual;
     actual = target.Index(id);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }