public async Task <IActionResult> GetOne(int id) { await Db.Connection.OpenAsync(); var query = new TipQuery(Db); var result = await query.FindOneAsync(id); if (result is null) { return(new NotFoundResult()); } return(new OkObjectResult(result)); }
public async Task <IActionResult> DeleteOne(int id) { await Db.Connection.OpenAsync(); var query = new TipQuery(Db); var result = await query.FindOneAsync(id); if (result is null) { return(new NotFoundResult()); } await result.DeleteAsync(); return(new OkResult()); }
public async Task <IActionResult> PutOne(int id, [FromBody] Tip body) { await Db.Connection.OpenAsync(); var query = new TipQuery(Db); var result = await query.FindOneAsync(id); if (result is null) { return(new NotFoundResult()); } result.tip = body.tip; result.message = body.message; result.userId = body.userId; result.gameId = body.gameId; await result.UpdateAsync(); return(new OkObjectResult(result)); }