/// <summary> /// 添加用户其它信息 /// </summary> /// <param name="userOther"></param> /// <returns></returns> public async Task <int> AddUserOther(UserOtherVModel userOther) { return (await Task.Run( () => UserOthers.AddUserOther( UserOthers.UserOtherVModelToInfo(userOther)))); }
/// <summary> /// ViewModel 转 DataModel /// </summary> /// <param name="userotherVModel"></param> /// <returns></returns> public static UserOtherInfo UserOtherVModelToInfo(UserOtherVModel userotherVModel) { if (userotherVModel == null) { return(new UserOtherInfo()); } return(new UserOtherInfo { UserId = userotherVModel.UserId, PersonalityIntroduce = userotherVModel.PersonalityIntroduce }); }
public JsonResult Add(UserOtherVModel model) { var result = new JsonResultModel(); if (ModelState.IsValid) { //add result.ResultState = UserOthers.AddUserOther(UserOthers.UserOtherVModelToInfo(model)) > 0; } else { result.ResultState = false; result.Message = ModelStateHelper.GetAllErrorMessage(ModelState); } return(Json(result)); }
public async Task <ActionResult> SetInfo(UserVModel user, UserOtherVModel other, string province, string city, string area) { ModelState.Remove("Name"); ModelState.Remove("ConfirmPassword"); ModelState.Remove("Password"); ModelState.Remove("RoleId"); ModelState.Remove("Avatar"); if (!ModelState.IsValid) { return(Json(new JsonResultModel { Message = ModelStateHelper.GetAllErrorMessage(ModelState) })); } user.Id = CurrentUserInfo.Id; other.UserId = CurrentUserInfo.Id; var olduser = Users.GetUserById(CurrentUserInfo.Id); //邮箱修改需要重新验证 if (olduser.Email.ToLower() != user.Email.ToLower()) { user.EmailStatus = false; } else { user.EmailStatus = olduser.EmailStatus; } //修改基本信息 var status = UserPublic.UpdateUser(user); if (!status) { return(Json(new JsonResultModel { Message = "修改基本信息失败!" })); } var userOther = await Users.GetUserOtherById(user.Id); if (userOther == null || userOther.IsNull) { status = await UserPublic.AddUserOther(other) > 0; } else { status = UserPublic.UpdateUserOther(other); } if (!status) { return(Json(new JsonResultModel { Message = "修改信息失败!" })); } await UserPublic.DeleteUserPosition(CurrentUserInfo.Id); #region 地址 if (!string.IsNullOrEmpty(province)) { int pid = await UserPublic.AddUserPosition(new UserPositionVModel { Code = int.Parse(province), Type = 0, UserId = CurrentUserInfo.Id }); if (pid == 0) { return(Json(new JsonResultModel { Message = "修改居住地区信息失败,!" })); } } if (!string.IsNullOrEmpty(city)) { int cid = await UserPublic.AddUserPosition(new UserPositionVModel { Code = int.Parse(city), Type = 1, UserId = CurrentUserInfo.Id }); if (cid == 0) { return(Json(new JsonResultModel { Message = "修改居住地区信息失败,!" })); } } if (!string.IsNullOrEmpty(area)) { int aid = await UserPublic.AddUserPosition(new UserPositionVModel { Code = int.Parse(area), Type = 2, UserId = CurrentUserInfo.Id }); if (aid == 0) { return(Json(new JsonResultModel { Message = "修改居住地区信息失败,!" })); } } #endregion UsersLogin.RefreshCookieUserInfo(CurrentUserInfo.Id); return(Json(new JsonResultModel { ResultState = true, Message = "修改成功!" })); }
/// <summary> /// 修改用户其它信息 /// </summary> /// <param name="userother"></param> /// <returns></returns> public bool UpdateUserOther(UserOtherVModel userother) { return (UserOthers.UpdateUserOther(UserOthers.UserOtherVModelToInfo(userother)) > 0); }
public ActionResult Add() { var vm = new UserOtherVModel(); return(View(vm)); }