#region mysql
[Route("add2")]
[HttpPost]
public ContentResult add2([FromForm] body c)
{
//查询
var result = Model.Connect.Mysql.Query().Where(a => a.key == c.key).FirstOrDefault();
string msg = "已经存在";
if (result == null)
{//添加
result = Model.Connect.Mysql.Insert(c);
}
else
{
if (c.type == "update")
{//修改
int count = Model.Connect.Mysql.Update(a => a.key == a.key, n => new body()
{
values = c.values,
time = c.time
});
}
}
string strJson = JsonConvert.SerializeObject(result);
return new ContentResult { Content = msg + strJson, ContentType = "application/json" };
}
#endregion