public async Task <bool> WriteJson(Guid accountId, string data) { if (!data.IsValidJson()) { return(false); } if (!data.IsValidContentModel()) { return(false); } // Get content key Guid contentKey = data.ExtractContentKey(); // 1. get all links var links = await _linkReader.GetLinks(accountId, contentKey); // 2. if there are no links, add a root link and a content item if (!links.Any()) { links.Add(await GenerateRootContent(accountId, contentKey, data)); } // 3. for all linked content items, update 'data' and store TableBatchOperation batchOperation = new TableBatchOperation(); foreach (var link in links) { Guid contentId = Guid.Parse(link.RowKey.FirstPartOfCompositeIndex()); var content = await _contentReader.ReadData(accountId, contentId); var mergedData = _dataUpdater.Update(content, contentId, data); BatchInsertContent(accountId, contentId, mergedData, batchOperation); } // commit batch update IList <TableResult> insertContentResults = await _contentTable.ExecuteBatchAsync(batchOperation); if (insertContentResults.Any(r => !r.HttpStatusCode.IsSuccessfulHttpStatusCode())) { return(false); } else { return(true); } }
public IActionResult Index(int?page = 1) { var result = _linkReader.GetLinks(page.Value); return(Ok(result)); }
/// <summary> /// Raised when the page is loaded /// </summary> /// <param name="sender">Element which raised the event.</param> /// <param name="e">Event arguments</param> protected void Page_Load(object sender, EventArgs e) { repeaterLinks.DataSource = _webservice.GetLinks(); repeaterLinks.DataBind(); }
public IActionResult Index() { var alllinks = _linkReader.GetLinks(); return(View(alllinks)); }