最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

使用Dictionary接收前端數(shù)據(jù),并用反射更新對像數(shù)據(jù)

2021-12-20 21:17 作者:Tuple_元組  | 我要投稿
  • 前端調(diào)用方式

?wx.request({

????????????url:?app.globalData.serverHttpUrl?+?"/JoinTeam/UpdateLeader",

????????????data:?{?TeamId:?thisProxy.data.theTeam.TeamId,?PlayerId:?e.currentTarget.id?},

????????????method:?'PUT',

????????????header:?{?'Cookie':?wx.getStorageSync('wxloginToken'),'content-type':?'application/x-www-form-urlencoded'?},

????????????success:?(res)?=>?{

????????????????console.log(res)

????????????}

})

  • 控制器

? ? ? ? /// <summary>

? ? ? ? /// 變更球隊(duì)相關(guān)信息

? ? ? ? /// </summary>

? ? ? ? /// <param name="teamNewInfo"></param>

? ? ? ? /// <param name="uploadFiles"></param>

? ? ? ? /// <returns></returns>

? ? ? ? [HttpPut("Update")]

? ? ? ? public async Task<JsonResult> PutAsync([FromForm] Dictionary<string, string> DictKeyValue, [FromForm] IFormCollection uploadFiles)

? ? ? ? {

? ? ? ? ? ? return new JsonResult(await _DataTeamRep.UpdateRecInfo(DictKeyValue));

? ? ? ? }

  • 數(shù)據(jù)操作? ?

? ? ? ? /// <summary>

? ? ? ? /// 更新記錄信息

? ? ? ? /// </summary>

? ? ? ? /// <param name="RecNewInfo">新的球隊(duì)信息</param>

? ? ? ? /// <param name="tempLogos">新的球隊(duì)Logo文件</param>

? ? ? ? /// <returns></returns>

? ? ? ? public async Task<VMResult<MTeam>> UpdateRecInfo(Dictionary<string, string> DictKeyValue)

? ? ? ? {

? ? ? ? ? ? if (DictKeyValue==null || !DictKeyValue.Keys.Contains("Id"))

? ? ? ? ? ? {

? ? ? ? ? ? ? ? return new VMResult<MTeam>() { ResultCode = -1, ResultMsg = "S:參數(shù)不正確",ResultEntity=null };

? ? ? ? ? ? }

? ? ? ? ? ? //查詢需要修改的球隊(duì)記錄。

? ? ? ? ? ? MTeam WillUpdateRec = await _DbContext.tb_team.FindAsync(DictKeyValue["Id"]);

? ? ? ? ? ? if (WillUpdateRec == null)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? return new VMResult<MTeam>() { ResultCode = -2, ResultMsg = "S:未找到球隊(duì)", ResultEntity = null };

? ? ? ? ? ? }

? ? ? ? ? ? //更新需要更新的字段

? ? ? ? ? ? List<string> NoUpdateFields = new() { "Id", "CreateTime" };

? ? ? ? ? ? var RecNewInfoProperties = WillUpdateRec.GetType().GetProperties();

? ? ? ? ? ? foreach (var item in RecNewInfoProperties.Where(x => !NoUpdateFields.Contains(x.Name)).ToList())

? ? ? ? ? ? {

? ? ? ? ? ? ? ? if(DictKeyValue.Keys.Contains( item.Name))

? ? ? ? ? ? ? ? {

?switch (item.PropertyType.Name)

? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? case "Int32":

? ? ? ? ? ? ? ? ? ? ? ? ? ? item.SetValue(WillUpdateRec, Int32.Parse(DictKeyValue[item.Name]));

? ? ? ? ? ? ? ? ? ? ? ? ? ? break;

? ? ? ? ? ? ? ? ? ? ? ? case "String":

? ? ? ? ? ? ? ? ? ? ? ? ? ? item.SetValue(WillUpdateRec, DictKeyValue[item.Name]);

? ? ? ? ? ? ? ? ? ? ? ? ? ? break;

? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }

? ? ? ? ? ? if (await _DbContext.SaveChangesAsync() > 0)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? return new VMResult<MTeam>() { ResultCode = -2, ResultMsg = "S:更新成功", ResultEntity = WillUpdateRec };

? ? ? ? ? ? }

? ? ? ? ? ? else

? ? ? ? ? ? {

? ? ? ? ? ? ? ? return new VMResult<MTeam>() { ResultCode = -3, ResultMsg = "S:未更新信息", ResultEntity = null };

? ? ? ? ? ? }

? ? ? ? }

? ? }

}

使用Dictionary接收前端數(shù)據(jù),并用反射更新對像數(shù)據(jù)的評論 (共 條)

分享到微博請遵守國家法律
平罗县| 苍溪县| 綦江县| 荆州市| 根河市| 荣昌县| 浑源县| 车致| 叶城县| 敖汉旗| 神木县| 环江| 南郑县| 嘉黎县| 福泉市| 阳山县| 阜南县| 清河县| 新龙县| 上饶市| 菏泽市| 扎兰屯市| 昭通市| 东兴市| 松江区| 阜南县| 忻城县| 北安市| 延寿县| 化德县| 天全县| 上虞市| 依兰县| 新昌县| 宁化县| 嫩江县| 溧水县| 万荣县| 渑池县| 绥德县| 锦屏县|