public static ExpenseItem ToModel(this IExpenseItemEntity entity) { var expenseItem = new ExpenseItem { Id = new StorageKey(KeyGenerator.ExpenseItemEntitySuffix(entity.RowKey)).InvertedTicks, Amount = entity.Amount.HasValue ? entity.Amount.Value : 0, Description = entity.Description, ReceiptUrl = null, ReceiptThumbnailUrl = null }; if (entity.HasReceipt.HasValue && entity.HasReceipt.Value) { var imageName = expenseItem.Id + ".jpg"; var account = CloudConfiguration.GetStorageAccount(AzureConnectionStrings.DataConnection); string thumbnail = Path.Combine(account.BlobEndpoint.ToString(), AzureStorageNames.ReceiptContainerName, "thumbnails", imageName); string receipt = Path.Combine(account.BlobEndpoint.ToString(), AzureStorageNames.ReceiptContainerName, imageName); expenseItem.ReceiptThumbnailUrl = new Uri(thumbnail); expenseItem.ReceiptUrl = new Uri(receipt); } return(expenseItem); }