public async Task Save(Page page) { var table = await GetTable(); var tableEntity = ToPageTableEntity(page); TableOperation insertOperation = TableOperation.Insert(tableEntity); await table.ExecuteAsync(insertOperation).ConfigureAwait(false); }
public async Task<IHttpActionResult> SaveASinglePage(Page page) { var persistence = new PagePersistence(); page.Day = DateTime.Today; await persistence.Save(page); return Ok(page); }
public async Task Save(Page[] pages) { var table = await GetTable(); var batchInsertOperation = new TableBatchOperation(); foreach (var page in pages) { batchInsertOperation.Add(TableOperation.Insert(ToPageTableEntity(page))); } await table.ExecuteBatchAsync(batchInsertOperation); }
public async Task<IHttpActionResult> SaveAMultiplePage(Page[] pages) { var persistence = new PagePersistence(); foreach (var page in pages) { page.Day = DateTime.Today; } await persistence.Save(pages); return Ok(pages); }
private PageTableEntity ToPageTableEntity(Page page) { return new PageTableEntity { PartitionKey = page.Day.Ticks.ToString(), RowKey = HttpUtility.UrlEncode(page.Uri.AbsoluteUri), Day = page.Day, Url = page.Uri.AbsoluteUri, Domain = page.Domain, Path = page.Path, Title = page.Title, Description = page.Description, Tags = page.Tags }; }