Inheritance: Microsoft.WindowsAzure.Storage.Table.TableEntity
Ejemplo n.º 1
0
        public PhotoModel(PhotoEntity entity)
        {
            this.ID = entity.ID;

            this.StorageAccountName = entity.StorageAccountName;
            this.ServerFileName     = entity.ServerFileName;
            this.Owner        = entity.Owner;
            this.OwnerName    = entity.OwnerName;
            this.BlobURL      = entity.BlobURL;
            this.ThumbnailURL = entity.ThumbnailURL;
            this.DateAdded    = entity.DateAdded;
            this.OriginRegion = entity.OriginRegion;
        }
Ejemplo n.º 2
0
        public PhotoModel(PhotoEntity entity)
        {
            this.ID = entity.ID;

            this.StorageAccountName = entity.StorageAccountName;
            this.ServerFileName = entity.ServerFileName;
            this.Owner = entity.Owner;
            this.OwnerName = entity.OwnerName;
            this.BlobURL = entity.BlobURL;
            this.ThumbnailURL = entity.ThumbnailURL;
            this.DateAdded = entity.DateAdded;
            this.OriginRegion = entity.OriginRegion;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Saves an entity to Azure table storage
        /// </summary>
        /// <param name="tableName">The name of the table to save to</param>
        /// <param name="model">The PhotoModel object to be saved</param>
        /// <returns>System.String - the HTTP status code of the save operation</returns>
        public async Task<string> SaveToTableStorageAsync(            
            string tableName,
            PhotoModel model)
        {
            //We use the DateAdded field for cross-partition queries
            DateTime now = System.DateTime.Now;

            model.DateAdded = now;

            PhotoEntity entity = new PhotoEntity(model);
            
            //These properties are used in a full table scan to populate
            //all photos for all users.  Needed as some way to get the 
            //items for a single day for all users.
            entity.DayAdded = now.Day;
            entity.MonthAdded = now.Month;
            entity.YearAdded = now.Year;
            
            var client = _account.CreateCloudTableClient();
            var table = client.GetTableReference(tableName);
            var operation = TableOperation.InsertOrReplace(entity);

            var result = await table.ExecuteAsync(operation);

            //TODO:  Do we need to check the HTTP status code here?
            return result.HttpStatusCode.ToString();
        }