public void DeletePhoto(PhotoEntity photo)
        {
            CloudTable table = this.ServiceClient.GetTableReference("Photos");
            TableOperation retrieveOperation = TableOperation.Retrieve<PhotoEntity>(photo.PartitionKey, photo.RowKey);
            TableResult retrievedResult = table.Execute(retrieveOperation);
            PhotoEntity deleteEntity = (PhotoEntity)retrievedResult.Result;

            if (deleteEntity != null)
            {
                TableOperation deleteOperation = TableOperation.Delete(deleteEntity);
                table.Execute(deleteOperation);
            }
        }
        public void DeletePhoto(PhotoEntity photo)
        {
            var table = ServiceClient.GetTableReference("Photos");
            var retrieveOperation = TableOperation.Retrieve<PhotoEntity>(photo.PartitionKey, photo.RowKey);
            var retrievedResult = table.Execute(retrieveOperation);
            var deleteEntity = retrievedResult.Result as PhotoEntity;

            if (deleteEntity != null)
            {
                var deleteOperation = TableOperation.Delete(deleteEntity);
                table.Execute(deleteOperation);
            }
        }
        public void UpdatePhoto(PhotoEntity photo)
        {
            var table = ServiceClient.GetTableReference("Photos");
            var retrieveOperation = TableOperation.Retrieve<PhotoEntity>(photo.PartitionKey, photo.RowKey);
            var retrievedResult = table.Execute(retrieveOperation);
            var updateEntity = retrievedResult.Result as PhotoEntity;

            if (updateEntity != null)
            {
                updateEntity.Description = photo.Description;
                updateEntity.Title = photo.Title;

                var replaceOperation = TableOperation.Replace(updateEntity);
                table.Execute(replaceOperation);
            }
        }
        public void UpdatePhoto(PhotoEntity photo)
        {
            CloudTable table = this.ServiceClient.GetTableReference("Photos");
            TableOperation retrieveOperation = TableOperation.Retrieve<PhotoEntity>(photo.PartitionKey, photo.RowKey);

            TableResult retrievedResult = table.Execute(retrieveOperation);
            PhotoEntity updateEntity = (PhotoEntity)retrievedResult.Result;

            if (updateEntity != null)
            {
                updateEntity.Description = photo.Description;
                updateEntity.Title = photo.Title;

                TableOperation replaceOperation = TableOperation.Replace(updateEntity);
                table.Execute(replaceOperation);
            }
        }
 public void AddPhoto(PhotoEntity photo)
 {
     TableOperation operation = TableOperation.Insert(photo);
     CloudTable table = this.ServiceClient.GetTableReference("Photos");
     table.Execute(operation);
 }
 private PhotoViewModel ToViewModel(PhotoEntity photo)
 {
     return new PhotoViewModel
     {
         PartitionKey = photo.PartitionKey,
         RowKey = photo.RowKey,
         Title = photo.Title,
         Description = photo.Description
     };
 }
        private PhotoEntity FromViewModel(PhotoViewModel photoViewModel)
        {
            var photo = new PhotoEntity
                {
                    Title = photoViewModel.Title,
                    Description = photoViewModel.Description
                };

            photo.PartitionKey = photoViewModel.PartitionKey ?? photo.PartitionKey;
            photo.RowKey = photoViewModel.RowKey ?? photo.RowKey;
            return photo;
        }
 public async Task DeletePhotoAsync(PhotoEntity entityToDelete)
 {
     var table           = this.ServiceClient.GetTableReference("Photos");
     var deleteOperation = TableOperation.Delete(entityToDelete);
     await table.ExecuteAsync(deleteOperation);
 }
 public async Task UpdatePhotoAsync(PhotoEntity entityToUpdate)
 {
     var table     = this.ServiceClient.GetTableReference("Photos");
     var operation = TableOperation.Replace(entityToUpdate);
     await table.ExecuteAsync(operation);
 }
 public async Task AddPhotoAsync(PhotoEntity photo)
 {
     var table     = this.ServiceClient.GetTableReference("Photos");
     var operation = TableOperation.Insert(photo);
     await table.ExecuteAsync(operation);
 }
示例#11
0
 private PhotoEntity FromViewModel(PhotoViewModel photoViewModel)
 {
     var photo = new PhotoEntity(this.User.Identity.Name);
     photo.RowKey = photoViewModel.RowKey ?? photo.RowKey;
     photo.Title = photoViewModel.Title;
     photo.Description = photoViewModel.Description;
     return photo;
 }
 public async Task DeletePhotoAsync(PhotoEntity entityToDelete)
 {
     var table = this.ServiceClient.GetTableReference("Photos");
     var deleteOperation = TableOperation.Delete(entityToDelete);
     await table.ExecuteAsync(deleteOperation);
 }
 public async Task UpdatePhotoAsync(PhotoEntity entityToUpdate)
 {
     var table = this.ServiceClient.GetTableReference("Photos");
     var operation = TableOperation.Replace(entityToUpdate);
     await table.ExecuteAsync(operation);
 }
 public async Task AddPhotoAsync(PhotoEntity photo)
 {
     var table = this.ServiceClient.GetTableReference("Photos");
     var operation = TableOperation.Insert(photo);
     await table.ExecuteAsync(operation);
 }
 public void AddPhoto(PhotoEntity photo)
 {
     var table = ServiceClient.GetTableReference("Photos");
     var operation = TableOperation.Insert(photo);
     table.Execute(operation);
 }