2018-03-28 22:08:49 +00:00
|
|
|
|
using BotSharp.Core.Engines;
|
2018-01-02 18:05:35 +00:00
|
|
|
|
using DotNetToolkit;
|
2017-12-30 20:26:35 +00:00
|
|
|
|
using EntityFrameworkCore.BootKit;
|
2018-03-19 02:07:36 +00:00
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
2017-12-30 20:26:35 +00:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using Microsoft.Data.Sqlite;
|
|
|
|
|
|
using MySql.Data.MySqlClient;
|
2018-01-02 18:05:35 +00:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
2017-12-30 20:26:35 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
2018-03-28 22:08:49 +00:00
|
|
|
|
namespace BotSharp.Core.RestApi
|
2017-12-30 20:26:35 +00:00
|
|
|
|
{
|
2018-03-19 02:07:36 +00:00
|
|
|
|
//[Authorize]
|
2017-12-30 20:26:35 +00:00
|
|
|
|
[Produces("application/json")]
|
|
|
|
|
|
[Route("bot/[controller]")]
|
|
|
|
|
|
public class EssentialController : ControllerBase
|
|
|
|
|
|
{
|
|
|
|
|
|
protected Database dc { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public EssentialController()
|
|
|
|
|
|
{
|
2018-03-19 02:07:36 +00:00
|
|
|
|
dc = new DefaultDataContextLoader().GetDefaultDc();
|
2017-12-30 20:26:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-02 18:05:35 +00:00
|
|
|
|
[HttpPatch("{table}/{id}")]
|
|
|
|
|
|
public IActionResult Patch([FromRoute] String table, [FromRoute] String id, [FromBody] JObject jObject)
|
|
|
|
|
|
{
|
|
|
|
|
|
var patch = new DbPatchModel
|
|
|
|
|
|
{
|
|
|
|
|
|
Table = table,
|
|
|
|
|
|
Id = id,
|
|
|
|
|
|
Values = jObject.ToDictionary()
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
dc.Patch<IDbRecord>(patch);
|
|
|
|
|
|
|
|
|
|
|
|
return Ok();
|
|
|
|
|
|
}
|
2017-12-30 20:26:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|