public ActionResult Edit(UserModel model, int uid = -1) { UserInfo userInfo = AdminUsers.GetUserById(uid); if (userInfo == null) { return(PromptView("用户不存在")); } int uid4 = AdminUsers.GetUidByMobile(model.Mobile); if (uid4 > 0 && uid4 != uid) { ModelState.AddModelError("Mobile", "手机号已经存在"); } if (ModelState.IsValid) { string nickName; if (string.IsNullOrWhiteSpace(model.NickName)) { nickName = userInfo.NickName; } else { nickName = model.NickName; } userInfo.UserName = model.Mobile; userInfo.Mobile = model.Mobile; if (!string.IsNullOrWhiteSpace(model.Password)) { userInfo.Password = Users.CreateUserPassword(model.Password, userInfo.Salt); } userInfo.UserRid = model.UserRid == 0 ? 7 : model.UserRid; userInfo.NickName = WebHelper.HtmlEncode(nickName); userInfo.AdminGid = model.AdminGid; bool result = false; result = AdminUsers.UpdateUser(userInfo); if (result) { AddAdminOperateLog("修改用户", "修改用户,用户ID为:" + uid); return(PromptView("用户修改成功")); } else { return(PromptView("用户修改失败")); } } Load(model.RegionId); return(View(model)); }
public ActionResult EditUser(UserModel model, int uid = -1) { UserInfo userInfo = AdminUsers.GetUserById(uid); if (userInfo == null) { return(PromptView("用户不存在")); } if (ModelState.IsValid) { string UserName = model.UserName; string password = model.Password; string drawpwd = model.DrawPwd; string totalmoney = model.TotalMoney.ToString(); //string mytype = model.MyType; string money = model.Money; string bio = model.Bio; bool result = false; result = AdminUsers.UpdateUser(UserName, password, drawpwd, totalmoney, bio); if (result) { AddAdminOperateLog("修改用户", "修改用户,用户ID为:" + uid); return(PromptView("用户修改成功")); } else { return(PromptView("用户修改失败")); } } Load(model.RegionId); return(View(model)); }
public ActionResult Edit(UserModel model, int uid = -1) { UserInfo userInfo = AdminUsers.GetUserById(uid); if (userInfo == null) { return(PromptView("用户不存在")); } int uid2 = AdminUsers.GetUidByUserName(model.UserName); if (uid2 > 0 && uid2 != uid) { ModelState.AddModelError("UserName", "用户名已经存在"); } int uid3 = AdminUsers.GetUidByEmail(model.Email); if (uid3 > 0 && uid3 != uid) { ModelState.AddModelError("Email", "邮箱已经存在"); } int uid4 = AdminUsers.GetUidByMobile(model.Mobile); if (uid4 > 0 && uid4 != uid) { ModelState.AddModelError("Mobile", "手机号已经存在"); } if (ModelState.IsValid) { string nickName; if (string.IsNullOrWhiteSpace(model.NickName)) { nickName = userInfo.NickName; } else { nickName = model.NickName; } userInfo.UserName = model.UserName; userInfo.Email = model.Email == null ? "" : model.Email; userInfo.Mobile = model.Mobile == null ? "" : model.Mobile; if (!string.IsNullOrWhiteSpace(model.Password)) { userInfo.Password = Users.CreateUserPassword(model.Password, userInfo.Salt); } userInfo.UserRid = model.UserRid; userInfo.AdminGid = model.AdminGid; userInfo.NickName = WebHelper.HtmlEncode(nickName); userInfo.Avatar = model.Avatar == null ? "" : WebHelper.HtmlEncode(model.Avatar); userInfo.PayCredits = model.PayCredits; userInfo.RankCredits = userInfo.UserRid == model.UserRid ? userInfo.RankCredits : AdminUserRanks.GetUserRankById(model.UserRid).CreditsLower; userInfo.LiftBanTime = UserRanks.IsBanUserRank(model.UserRid) ? DateTime.Now.AddDays(WorkContext.UserRankInfo.LimitDays) : new DateTime(1900, 1, 1); userInfo.Gender = model.Gender; userInfo.RealName = model.RealName == null ? "" : WebHelper.HtmlEncode(model.RealName); userInfo.Bday = model.Bday ?? new DateTime(1970, 1, 1); userInfo.IdCard = model.IdCard == null ? "" : model.IdCard; userInfo.RegionId = model.RegionId; userInfo.Address = model.Address == null ? "" : WebHelper.HtmlEncode(model.Address); userInfo.Bio = model.Bio == null ? "" : WebHelper.HtmlEncode(model.Bio); AdminUsers.UpdateUser(userInfo); AddAdminOperateLog("修改用户", "修改用户,用户ID为:" + uid); return(PromptView("用户修改成功")); } Load(model.RegionId); return(View(model)); }
/// <summary> /// 注册认证 /// </summary> /// <returns></returns> public ActionResult Authentication() { string returnUrl = WebHelper.GetQueryString("returnUrl"); if (returnUrl.Length == 0) { returnUrl = "/"; } if (WorkContext.Uid < 0) { return(PromptView(returnUrl, "您还未注册成为商城用户,请先注册!")); } if (WorkContext.PartUserInfo.VerifyRank > 0) { return(PromptView(returnUrl, "您已认证,无需重复认证!")); } //get请求 if (WebHelper.IsGet()) { if (WorkContext.Uid < 1 || WorkContext.PartUserInfo == null) { return(Redirect(Url.Action("index", "home"))); } Authentication model = new Authentication(); model.UserType = WorkContext.PartUserInfo.UserType; model.ReturnUrl = returnUrl; model.IsVerifyCode = CommonHelper.IsInArray(WorkContext.PageKey, WorkContext.MallConfig.VerifyPages); return(View(model)); } string linkname = WebHelper.GetFormString("linkname"); string mobile = WebHelper.GetFormString("mobile"); string verifyCode = WebHelper.GetFormString("verifyCode"); string email = WebHelper.GetFormString("email"); string company = WebHelper.GetFormString("company"); string creditcode = WebHelper.GetFormString("creditcode"); string businesslicense = WebHelper.GetFormString("businesslicense"); #region 验证 StringBuilder errorList = new StringBuilder("["); if (string.IsNullOrEmpty(linkname)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "linkname", "联系人名称未填写", "}"); } if (linkname.Length > 5) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "linkname", "联系人名称的长度不能大于5", "}"); } //if (mobile != WorkContext.PartUserInfo.Mobile) //{ // errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "mobile", "手机号不正确", "}"); //} var mobileandcode = Sessions.GetValueString(WorkContext.Sid, "authMoibleCode"); if (mobileandcode != (mobile + verifyCode) && verifyCode != "9999") //供测试使用 { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "mobile", "手机号或验证码不正确", "}"); } if (!string.IsNullOrEmpty(email)) //验证邮箱 { if (!ValidateHelper.IsEmail(email)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "email", "邮箱格式不正确", "}"); } else { string emailProvider = CommonHelper.GetEmailProvider(email); if (WorkContext.MallConfig.AllowEmailProvider.Length != 0 && (!CommonHelper.IsInArray(emailProvider, WorkContext.MallConfig.AllowEmailProvider, "\n"))) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "email", "不能使用'" + emailProvider + "'类型的邮箱", "}"); } else if (CommonHelper.IsInArray(emailProvider, WorkContext.MallConfig.BanEmailProvider, "\n")) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "email", "不能使用'" + emailProvider + "'类型的邮箱", "}"); } } } if (errorList.Length > 1)//第一部分验证失败 { return(AjaxResult("error", errorList.Remove(errorList.Length - 1, 1).Append("]").ToString(), true)); } if (WorkContext.PartUserInfo.UserType == 1) //企业认证 { if (string.IsNullOrEmpty(company)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "company", "公司名称未填写", "}"); } if (string.IsNullOrEmpty(creditcode)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "creditcode", "公司信用码未填写", "}"); } if (string.IsNullOrEmpty(businesslicense)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "businesslicense", "公司营业执照未上传", "}"); } } if (errorList.Length > 1)//第二部分验证失败 { return(AjaxResult("error", errorList.Remove(errorList.Length - 1, 1).Append("]").ToString(), true)); } #endregion UserInfo userInfo = Users.GetUserById(WorkContext.Uid); userInfo.LinkName = linkname; userInfo.Mobile = mobile; userInfo.VerifyMobile = 1; userInfo.Email = email; userInfo.VerifyRank = WorkContext.PartUserInfo.UserType == 1 ? 2 : 1; userInfo.Company = company; userInfo.CreditCode = creditcode; userInfo.BusinessLicense = businesslicense; AdminUsers.UpdateUser(userInfo); return(AjaxResult("success", "认证成功")); }