- public class MyAPI : ForguncyApi
- {
- [Post]
- public async Task TestPostAPI()
- {
- //获取post请求的数据
- var form = await this.Context.Request.ReadFormAsync();
- var name = form["name"].FirstOrDefault();
- var department = form["department"].FirstOrDefault();
- string result = name + department;
- await this.Context.Response.WriteAsync(result);
- //使用AddTableData方法向员工表中添加数据
- this.DataAccess.AddTableData("员工表", new Dictionary<string, object> { { "姓名", name }, { "部门", department } });
- }
- }
复制代码 |