public async Task <Guid?> SubmitDatasetIssue(ClaimsPrincipal user, DatasetIssue issue, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var doc = await this.RetrieveDatasetDocument(issue.DatasetId, cancellationToken); if (doc == null) { throw new InvalidOperationException("Invalid dataset id."); } var userId = GetUserId(user); if (!userId.HasValue) { return(null); } var name = GetUserName(user); var email = GetUserEmail(user); var options = new RequestOptions { PartitionKey = new PartitionKey(issue.DatasetId.ToString()) }; var uri = this.UserDataDocumentCollectionUri; var record = new DatasetIssueStorageItem { Id = Guid.NewGuid(), DatasetId = issue.DatasetId, Name = issue.Name, Description = issue.Description, ContactName = issue.ContactName, ContactInfo = issue.ContactInfo, UserId = userId.Value, UserName = name, UserEmail = email, }; await this.Client.CreateDocumentAsync(uri, record, options).ConfigureAwait(false); return(record.Id); }
public async Task <IActionResult> SubmitNomination([FromBody] DatasetIssue issue, CancellationToken cancellationToken) { await this.Storage.SubmitDatasetIssue(this.User, issue, cancellationToken); return(this.Ok(true)); }