示例#1
0
        public async Task <IActionResult> DeleteAll()
        {
            await Db.Connection.OpenAsync();

            var query = new UsersPostQuery(Db);
            await query.DeleteAllAsync();

            return(new OkResult());
        }
示例#2
0
        public async Task <IActionResult> GetLatest()
        {
            await Db.Connection.OpenAsync();

            var query  = new UsersPostQuery(Db);
            var result = await query.LatestPostsAsync();

            //CreateTableAndInsertData();


            return(new OkObjectResult(result));
        }
示例#3
0
        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));
        }
示例#4
0
        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));
        }