using YLErp.Modules.UnderlyingModule; namespace YLErp.Web.Controllers { public class Underlying_BasisCurveController : BaseController { // GET: Underlying_BasisCurve [MyAuthorize("报价管理-基差曲线")] public ActionResult Underlyingbasis_curveList() { return View(); } public ActionResult AddUnderlyingbasis_curve() { return View(); } public ActionResult Underlying_BasiscurveView(int enid) { var res = new Underlying_BasisCurveService(CurUser).GetUnderlying_BasisCurve(enid); return View(res); } public JsonResult GetUnderlyingName(string Underlyingcode) { var res = DataCacheProvider.GetUnderlyingDataSource().GetData(Underlyingcode).UnderlyingName; return Json(res); } public JsonResult UnderlyingbasiscurveQuery(Underlying_basiscurveReq req) { var list = new Underlying_BasisCurveService(CurUser).SearchList(req); return Json(list); } public JsonResult SaveUnderlyingBasis_curve(Underlying_BasiscurveDot model) { if (model == null) { return JsonError("保存的对象不能为空"); } new Underlying_BasisCurveService(CurUser).SaveUnderlying_Basiscurve(model); return Json("添加成功"); } public JsonResult GetUnderlying_Basiscurve(int id) { if (id == 0) { return JsonError("请传入对象"); } var res = new Underlying_BasisCurveService(CurUser).GetBasketUnderlying_Basiscurve(id); return Json(res); } [HttpPost] public ActionResult SaveUnderlying_basiscurveEdit(Underlying_BasiscurveDot model) { var existUnderlying = yldb.underlying_basis_curve.FirstOrDefault(u => u.id == model.id); if (existUnderlying == null) { return JsonError("基差曲线列表中没有相关的标的"); } var underlying = yldb.underlying_basis_curve.Where(c => c.UnderlyingCode != existUnderlying.UnderlyingCode); if (underlying.Any(c => c.UnderlyingCode == model.UnderlyingCode)) { throw new ServiceException("基差曲线列表已经存在该标的"); } existUnderlying.UnderlyingId = model.UnderlyingId; existUnderlying.UnderlyingCode = model.UnderlyingCode; existUnderlying.InterpolationMethod = model.InterpolationMethod; existUnderlying.InterpolationData = JsonHelper.Stringify(model.InterpolationData); yldb.SaveChanges(); return Json("修改成功!"); } public ActionResult DeleteUnderlying_Basiscurve(string ids) { var datalist = ids.Split(','); if (datalist == null) { return JsonError("没有要删除的标的"); } var list = new List(); var datalist2 = Array.ConvertAll(datalist, c => int.Parse(c)); var data = yldb.underlying_basis_curve.Where(c => datalist2.Contains(c.id)); yldb.underlying_basis_curve.RemoveRange(data); yldb.SaveChanges(); return JsonSuccess("删除成功"); } } }