using Microsoft.AspNetCore.Mvc;
using YLErp.Cache;
using YLErp.DBModels;
using YLErp.Modules.SwapModule;
namespace YLErp.Web.Controllers
{
public class TrsOpenController : BaseController
{
private readonly YLContext db = new YLContext();
IYLCache _yLCache;
public TrsOpenController(IYLCache yLCache)
{
_yLCache=yLCache;
}
public ActionResult Index()
{
var model=db.trs_open_config.FirstOrDefault();
if (model == null)
{
model = new TrsOpenConfig();
}
return View(model);
}
///
/// 保存做市配置
///
///
public JsonResult SaveConfig(TrsOpenConfigDto trsOpenConfig)
{
var model = db.trs_open_config.FirstOrDefault();
if (model == null)
{
model = new TrsOpenConfig();
}
model.pmStartTime = trsOpenConfig.pmStartTime;
model.pmEndTime = trsOpenConfig.pmEndTime;
model.amEndTime = trsOpenConfig.amEndTime;
model.amStartTime = trsOpenConfig.amStartTime;
model.SetOpt(CurUser);
if (model.id==0)
{
db.trs_open_config.Add(model);
}
db.SaveChanges();
_yLCache.StringSetWithNoPrefix("TRS_Open_Hour", trsOpenConfig,TimeSpan.FromHours(8));
return JsonSuccess("");
}
}
}