public ActionResult ToPublic(string partitionKey, string rowKey)
        {
            CloudTableClient cloudTableClient = new CloudTableClient(this.UriTable, new StorageCredentials(this.AuthenticatedTableSas));
            var photoContext = new PhotoDataServiceContext(cloudTableClient);
            var photo = photoContext.GetById(partitionKey, rowKey);
            if (photo == null)
            {
                return this.HttpNotFound();
            }

            photoContext.DeletePhoto(photo);

            cloudTableClient = new CloudTableClient(this.UriTable, new StorageCredentials(this.PublicTableSas));
            photoContext = new PhotoDataServiceContext(cloudTableClient);
            photo.PartitionKey = "Public";
            photoContext.AddPhoto(photo);

            return RedirectToAction("Index");
        }
        public ActionResult DeleteConfirmed(string partitionKey, string rowKey)
        {
            var token = partitionKey == "Public" ? this.PublicTableSas : this.AuthenticatedTableSas;
            CloudTableClient cloudTableClient = new CloudTableClient(this.UriTable, new StorageCredentials(this.PublicTableSas));
            var photoContext = new PhotoDataServiceContext(cloudTableClient);
            PhotoEntity photo = photoContext.GetById(partitionKey, rowKey);
            photoContext.DeletePhoto(photo);

            //Deletes the Image from Blob Storage
            if (!string.IsNullOrEmpty(photo.BlobReference))
            {
                var blob = this.GetBlobContainer().GetBlockBlobReference(photo.BlobReference);
                blob.DeleteIfExists();
            }

            //Send delete notification
            var msg = new CloudQueueMessage("Photo Deleted");
            this.GetCloudQueue().AddMessage(msg);

            return this.RedirectToAction("Index");
        }
        public ActionResult DeleteConfirmed(string partitionKey, string rowKey)
        {
            if (ModelState.IsValid)
            {
                string token = partitionKey == "Public" ? this.PublicTableSas : this.AuthenticatedTableSas;

                CloudTableClient cloudTableClient = new CloudTableClient(this.UriTable, new StorageCredentials(token));
                var photoContext = new PhotoDataServiceContext(cloudTableClient);
                PhotoEntity photo = photoContext.GetById(partitionKey, rowKey);

                if (photo == null)
                {
                    return this.HttpNotFound();
                }

                photoContext.DeletePhoto(photo);

                //Deletes the Image from Blob Storage
                if (!string.IsNullOrEmpty(photo.BlobReference))
                {
                    var blob = this.GetBlobContainer().GetBlockBlobReference(photo.BlobReference);
                    blob.DeleteIfExists();
                }

                try
                {
                    //Send delete notification
                    var msg = new CloudQueueMessage(string.Format("Photo Deleted,{0}", photo.BlobReference));
                    this.GetCloudQueue().AddMessage(msg);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Trace.TraceInformation("Error", "Couldn't send notification");
                }

            }
            return this.RedirectToAction("Index");
        }
        public ActionResult DeleteConfirmed(string partitionKey, string rowKey)
        {
            CloudTableClient cloudTableClient = this.StorageAccount.CreateCloudTableClient();
            var photoContext = new PhotoDataServiceContext(cloudTableClient);
            PhotoEntity photo = photoContext.GetById(partitionKey, rowKey);
            photoContext.DeletePhoto(photo);

            //Deletes the Image from Blob Storage
            if (!string.IsNullOrEmpty(photo.BlobReference))
            {
                var blob = this.GetBlobContainer().GetBlockBlobReference(photo.BlobReference);
                blob.DeleteIfExists();
            }

            try
            {
                //Send delete notification
                var msg = new CloudQueueMessage("Photo Deleted");
                this.GetCloudQueue().AddMessage(msg);
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.TraceInformation("Error", "Couldn't send notification");
            }

            return this.RedirectToAction("Index");
        }
        public ActionResult DeleteConfirmed(string id)
        {
            this.RefreshAccessCredentials();

            //Delete information From Table Storage
            CloudTableClient cloudTableClient = new CloudTableClient(this.Uri, new StorageCredentials(Session["Sas"].ToString()));
            var photoContext = new PhotoDataServiceContext(cloudTableClient);
            PhotoEntity photo = photoContext.GetById("Public", id);

            if (photo == null)
            {
                photo = photoContext.GetById(this.User.Identity.Name, id);
                if (photo == null)
                {
                    return this.HttpNotFound();
                }
            }
            photoContext.DeletePhoto(photo);

            //Deletes the Image from Blob Storage
            if (!string.IsNullOrEmpty(photo.BlobReference))
            {
                var blob = this.GetBlobContainer().GetBlockBlobReference(photo.BlobReference);
                blob.DeleteIfExists();
            }

            //Send delete notification
            var msg = new CloudQueueMessage("Photo Deleted");
            this.GetCloudQueue().AddMessage(msg);

            return this.RedirectToAction("Index");
        }
        public ActionResult DeleteConfirmed(string partitionKey, string rowKey)
        {
            var cloudTableClient = this.storageAccount.CreateCloudTableClient();
            var photoContext = new PhotoDataServiceContext(cloudTableClient);
            var photo = photoContext.GetById(partitionKey, rowKey);
            photoContext.DeletePhoto(photo);

            if (!String.IsNullOrEmpty(photo.BlobReference))
            {
                var blob = GetBlobContainer().GetBlockBlobReference(photo.BlobReference);
                blob.DeleteIfExists();
            }

            return RedirectToAction("Index");
        }