public async Task <IEnumerable <StickerNote> > GetBoardNotesAsync(Guid boardId) { CloudTable notesTable = GetNotesTable(); // Create the CloudTable if it does not exist await notesTable.CreateIfNotExistsAsync(); // Construct the query operation for all customer entities where PartitionKey="Smith". TableQuery <StickerNoteEntity> query = new TableQuery <StickerNoteEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, boardId.ToString())); // Print the fields for each customer. TableContinuationToken token = null; var result = new List <StickerNote>(); do { TableQuerySegment <StickerNoteEntity> resultSegment = await notesTable.ExecuteQuerySegmentedAsync(query, token); token = resultSegment.ContinuationToken; foreach (StickerNoteEntity entity in resultSegment.Results) { var item = new StickerNote { Id = Guid.Parse(entity.RowKey), BoardId = Guid.Parse(entity.PartitionKey), Text = entity.Text, Severity = entity.Severity }; result.Add(item); } } while (token != null); return(result); }
public async Task <IActionResult> AddNote(string id, StickerNote note) { if (!ModelState.IsValid) { return(new BadRequestObjectResult(ModelState)); } note.Id = Guid.NewGuid(); await _boardNotesRepository.CreateAsync(note); return(RedirectToAction("Notes", new { id = note.BoardId.ToString() })); }
public async Task CreateAsync(StickerNote note) { CloudTable notesTable = GetNotesTable(); // Create a new customer entity. StickerNoteEntity entity = new StickerNoteEntity(); entity.PartitionKey = note.BoardId.ToString(); entity.RowKey = note.Id.ToString(); entity.Text = note.Text; entity.Severity = note.Severity; // Create the TableOperation that inserts the customer entity. TableOperation insertOperation = TableOperation.Insert(entity); // Execute the insert operation. await notesTable.ExecuteAsync(insertOperation); }