五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(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ù)的評論 (共 條)

分享到微博請遵守國家法律
乌海市| 甘南县| 黄梅县| 济源市| 水富县| 龙岩市| 名山县| 马关县| 类乌齐县| 泽库县| 峡江县| 沁阳市| 社旗县| 江永县| 新邵县| 梅州市| 临颍县| 项城市| 茶陵县| 高密市| 宿迁市| 兴和县| 长白| 琼结县| 和平县| 定陶县| 沧源| 绵竹市| 奉新县| 西青区| 南华县| 鹰潭市| 三河市| 大新县| 肇东市| 金昌市| 常山县| 昌都县| 射阳县| 陵水| 资溪县|