public async Task <IActionResult> DeleteAll() { await Db.Connection.OpenAsync(); var query = new UsersPostQuery(Db); await query.DeleteAllAsync(); return(new OkResult()); }
public async Task <IActionResult> GetLatest() { await Db.Connection.OpenAsync(); var query = new UsersPostQuery(Db); var result = await query.LatestPostsAsync(); //CreateTableAndInsertData(); return(new OkObjectResult(result)); }
public async Task <IActionResult> GetOne(int id) { await Db.Connection.OpenAsync(); var query = new UsersPostQuery(Db); var result = await query.FindOneAsync(id); if (result is null) { return(new NotFoundResult()); } return(new OkObjectResult(result)); }
public async Task <IActionResult> PutOne(int id, [FromBody] UsersModel body) { await Db.Connection.OpenAsync(); var query = new UsersPostQuery(Db); var result = await query.FindOneAsync(id); if (result is null) { return(new NotFoundResult()); } result.Name = body.Name; result.Address = body.Address; result.Contact = body.Contact; await result.UpdateAsync(); return(new OkObjectResult(result)); }