public async Task <IActionResult> FindOneAsync(int id) { using (_db) { await _db.Connection.OpenAsync(); var query = new PostQuery(_db); var result = await query.FindOneAsync(id); if (result == null) { return(new NotFoundResult()); } return(new OkObjectResult(result)); } }
public async Task <IActionResult> GetOne(int id) { using (var db = new AppDb(connection_string)) { await db.Connection.OpenAsync(); var query = new PostQuery(db); var result = await query.FindOneAsync(id); if (result == null) { return(new NotFoundResult()); } return(new OkObjectResult(result)); } }
public async Task <IActionResult> PutOne(int id, [FromBody] Post body) { using (var db = new AppDb(connection_string)) { await db.Connection.OpenAsync(); var query = new PostQuery(db); var result = await query.FindOneAsync(id); if (result == null) { return(new NotFoundResult()); } result.Content = body.Content; await result.UpdateAsync(); return(new OkObjectResult(result)); } }