public async Task OrderBy() { var para = this.ParaForm(); KeyvalM data = KeyValBll.OrderBy(para.orderby); await this.Json(new { errcode = data.ErrorCode, errmsg = data.ErrorMsg }); }
private IEnumerable <object> AllFieldList(IEnumerable <AssetM> data) { var redata = data.Select(o => new { o.Id, o.Title, o.Code, o.Amount, o.Value, o.Positions, o.Price, o.Remark, o.Profit, Risk = KeyValBll.CodeToTitle(o.Risk), ExcOrg = KeyValBll.CodeToTitle(o.ExcOrg), Kind = KeyValBll.CodeToTitle(o.Kind), Valuedate = o.ValueDate.ToString("yyyy/MM/dd HH:mm"), Expdate = o.ExpDate.ToString("yyyy/MM/dd HH:mm"), o.Rate, Action = KeyValBll.CodeToTitle(o.Action), Ctime = o.Ctime.ToString("yyyy/MM/dd HH:mm"), o.ItemCode, o.Enabled }); return(redata); }
public async Task OnOff() { // 客户端要传数据主键id,status=1/2,table名字 var para = this.ParaForm <BaseModel>(); bool isok = KeyValBll.OnOff(para); await this.Json(new { errcode = isok ? ErrCode.Success : 401 }); }
public async Task Add() { var para = this.ParaForm <KeyvalM>(); string verrmsg = Validate.CheckEntity <KeyvalM>(para, nameof(para.Title), nameof(para.Comment)); if (verrmsg != null) { await this.Json(new { errcode = 300, errmsg = verrmsg }); return; } if (string.IsNullOrWhiteSpace(para.Id)) { // 新增 KeyValBll.Add(para); } else { // 更新 KeyValBll.Update(para); } await this.Json(new { errmsg = para.ErrorMsg, errcode = para.ErrorCode }); }
public async Task Item() { var para = this.ParaForm <KeyvalM>(); KeyvalM data = KeyValBll.GetById(para.Id); if (data == null) { await this.Json(new { msg = AlertMsg.没有数据.ToString() }); return; } // 返回字段按需设定 var redata = new { data.Id, data.Title, data.Category, data.Comment, data.Ctime }; await this.Json(new { item = redata, errcode = 200 }); }
public async Task List() { // 支持传多个分组 KeyvalM para = this.ParaForm <KeyvalM>(); // get KVdata Dictionary <string, List <KeyvalM> > datadict = KeyValBll.AllByCategory(para); if (datadict == null) { await this.Json(new { errmsg = para.ErrorMsg }); return; } // 返回字段按需设定 Dictionary <string, IEnumerable <object> > redict = new Dictionary <string, IEnumerable <object> >(); string[] fields = null; if (!string.IsNullOrWhiteSpace(para.Fields)) { fields = para.Fields.Split(','); } foreach (var key in datadict.Keys) { // 按需字段列表 if (fields != null && fields.Length > 0) { redict[key] = SerializeHelp.ObjectsToDicts(datadict[key], fields); } else { redict[key] = AllFieldList(datadict[key]); } } // await this.Json(new { list = redict, errcode = 200 }); }