public static async Task <GrouperDocument> MakeDocumentAsync(HttpRequest request) { using StreamReader stream = new StreamReader(request.Body); string document = await stream.ReadToEndAsync(); return(GrouperDocument.FromJson(document)); }
private async Task <IList <GrouperDocumentEntry> > InternalGetDocumentEntriesAsync(string storedProcedure, IDictionary <string, object> parameters) { var result = new List <GrouperDocumentEntry>(); using (var conn = new SqlConnection(_connectionString)) { await conn.OpenAsync(); using (var cmd = new SqlCommand()) { cmd.Connection = conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = storedProcedure; cmd.AddParameters(parameters); using (var reader = await cmd.ExecuteReaderAsync()) { while (await reader.ReadAsync()) { result.Add(new GrouperDocumentEntry( document: GrouperDocument.FromJson(reader.GetString(5)), revision: reader.GetInt32(0), revisionCreated: reader.GetDateTime(1), isPublished: reader.GetBoolean(2), isDeleted: reader.GetBoolean(3), tags: (reader.IsDBNull(4) ? Array.Empty <string>() : reader.GetString(4).Split(',')) )); } } } } return(result); }
public async Task <IActionResult> ValidateDocument(string lang) { _stringResourceHelper.SetLanguage(lang); using StreamReader stream = new StreamReader(Request.Body); string document = await stream.ReadToEndAsync(); List <ValidationError> errors = new List <ValidationError>(); GrouperDocument.FromJson(document, errors); return(Ok(errors)); }