public AdminController() { db = new dbOperation(); vm = new StartUpViewModel(); Cvm = new ContactVM(); AB = new AzureBlobHelper(); pfm = new postedFileModel(); ws = new Webshop(); }
public HomeController() { db = new dbOperation(); vm = new StartUpViewModel(); Cvm = new ContactVM(); AB = new AzureBlobHelper(); pfm = new postedFileModel(); ES = new EmailService(); }
public GalleryViewModel GetListOfData(postedFileModel filemodel, string containerName) { GalleryViewModel galleryvm = new GalleryViewModel(); List <GalleryViewModel> list = new List <GalleryViewModel>(); CloudStorageAccount storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting("StorageConnectionString")); //Create the blob client. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); //Retrieve reference to a previously created container. CloudBlobContainer container = blobClient.GetContainerReference(containerName); //Loop over items within the container and output the length and URI. foreach (IListBlobItem item in container.ListBlobs(null, false)) { if (item.GetType() == typeof(CloudBlockBlob)) { CloudBlockBlob blob = (CloudBlockBlob)item; GalleryViewModel gvm = new GalleryViewModel() { URIName = blob.Uri.ToString(), PictureName = blob.Name.ToString(), ContainerName = containerName }; list.Add(gvm); } else if (item.GetType() == typeof(CloudPageBlob)) { CloudPageBlob pageBlob = (CloudPageBlob)item; GalleryViewModel gvm = new GalleryViewModel() { URIName = pageBlob.Uri.ToString(), PictureName = pageBlob.Name.ToString(), ContainerName = containerName }; list.Add(gvm); } else if (item.GetType() == typeof(CloudBlobDirectory)) { CloudBlobDirectory directory = (CloudBlobDirectory)item; GalleryViewModel gvm = new GalleryViewModel() { URIName = directory.Uri.ToString(), ContainerName = containerName }; list.Add(gvm); } } galleryvm.BlobList = list; return(galleryvm); }
//public AzureBlobHelper() //{ // _blobcontainer.CreateIfNotExists(); //} public void SaveDataToAzureBlob(postedFileModel filemodel, string ContainerName) { //CloudBlobContainer _blobcontainer = new CloudBlobContainer(null); CloudStorageAccount storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting("StorageConnectionString")); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference(ContainerName); HttpWebRequest _requestPage = (HttpWebRequest)WebRequest.Create(filemodel.filePath); HttpWebResponse _responseRequest = (HttpWebResponse)_requestPage.GetResponse(); CloudBlockBlob _blockblob = container.GetBlockBlobReference(filemodel.filename); //Createing a Blob // Create or overwrite the blob with contents from a local file. _blockblob.UploadFromStream(_responseRequest.GetResponseStream()); }
// GET: Gallery public GalleryController() { AB = new AzureBlobHelper(); gvm = new GalleryViewModel(); pfm = new postedFileModel(); }