public IActionResult EditUserProfiles(DetailsUserProfilesModel model) { long uid = model.Userid; //验证权限 if (!authorizerHelper.IsUserPower(uid)) { return(Json(new StatusMessageData(StatusMessageType.Error, "选中的用户中有人的权限比您高!"))); } UserProfiles userProfiles = userProfilesService.GetUserProfiles(uid); userProfiles.Sex = model.Sex; userProfiles.Age = model.Age; userProfiles.Birthday = model.Birthday; userProfiles.SexualOrientation = model.SexualOrientation; userProfiles.IsSexualorientationSecrecy = model.IsSexualorientationSecrecy; userProfiles.Marriage = model.Marriage; userProfiles.IsMarriageSecrecy = model.IsMarriageSecrecy; userProfiles.Provinces = model.Provinces; userProfiles.City = model.City; userProfiles.IsNowareaSecrecy = model.IsNowareaSecrecy; bool result = userProfilesService.EditUserProfiles(userProfiles); if (result) { return(Json(new StatusMessageData(StatusMessageType.Success, "操作成功!"))); } return(Json(new StatusMessageData(StatusMessageType.Error, "操作失败!"))); }
public IActionResult _DetailsUserProfiles(long userId) { UserProfiles userProfiles = userProfilesService.GetUserProfiles(userId); if (userProfiles == null) { //返回一个ajax用的错误页 return(View("/Views/Error/SystemErrorAjax.cshtml")); } //性别 Dictionary <int, string> sexValues = new Dictionary <int, string> { { -1, "未填" }, { 0, "男" }, { 1, "女" } }; ViewData["Sex"] = new SelectList(sexValues.Select(m => new { text = m.Value, value = m.Key.ToString() }), "value", "text", userProfiles.Sex); //性取向 Dictionary <int, string> sexualOrientationValues = new Dictionary <int, string> { { -1, "未填" }, { 1, "男" }, { 2, "女" }, { 3, "双性" } }; ViewData["SexualOrientation"] = new SelectList(sexualOrientationValues.Select(m => new { text = m.Value, value = m.Key.ToString() }), "value", "text", userProfiles.SexualOrientation); //婚姻状况 Dictionary <int, string> marriageValues = new Dictionary <int, string> { { -1, "未填" }, { 0, "未婚" }, { 1, "已婚" } }; ViewData["Marriage"] = new SelectList(marriageValues.Select(m => new { text = m.Value, value = m.Key.ToString() }), "value", "text", userProfiles.SexualOrientation); //婚姻状况是否保密 所在地是否保密 性取向是否保密 Dictionary <int, string> isMarriageSecrecyValues = new Dictionary <int, string> { { -1, "未填" }, { 0, "否" }, { 1, "是" } }; ViewData["IsOK"] = new SelectList(isMarriageSecrecyValues.Select(m => new { text = m.Value, value = m.Key.ToString() }), "value", "text", userProfiles.SexualOrientation); DetailsUserProfilesModel detailsUserProfilesModel = new DetailsUserProfilesModel() { Age = userProfiles.Age, Birthday = userProfiles.Birthday, City = userProfiles.City, Integrity = userProfiles.Integrity, IsMarriageSecrecy = userProfiles.IsMarriageSecrecy, IsNowareaSecrecy = userProfiles.IsNowareaSecrecy, IsSexualorientationSecrecy = userProfiles.IsSexualorientationSecrecy, Marriage = userProfiles.Marriage, Provinces = userProfiles.Provinces, Sex = userProfiles.Sex, SexualOrientation = userProfiles.SexualOrientation, Userid = userProfiles.Userid }; return(View(detailsUserProfilesModel)); }