Exemple #1
0
        public ActionResult EditUser(long userId)
        {
            pageResourceManager.InsertTitlePart("后台管理-编辑用户资料");
            ManageUsersEditModel model = null;
            string selectedValue       = "0";
            User   user = userService.GetUser(userId) as User;

            if (user != null)
            {
                model = user.AsEditModel();
            }
            ViewData["statusMessageData"] = TempData["statusMessage"];
            List <SelectListItem> items = new List <SelectListItem>();

            string[] reasons = { "亵渎", "广告", "发垃圾广告", "恶意攻击他人", "不雅的用户名", "恶意的链接或签名档", "其他" };
            for (int i = 0; i < reasons.Count(); i++)
            {
                items.Add(new SelectListItem {
                    Value = i.ToString(), Text = reasons.ElementAt(i)
                });
            }

            if (reasons.Contains(user.BanReason))
            {
                selectedValue = items.Where(n => n.Text == user.BanReason).FirstOrDefault().Value;
            }
            else
            {
                selectedValue = (reasons.Count() - 1).ToString();
            }
            ViewData["reasons"] = new SelectList(items, "Value", "Text", selectedValue);
            return(View(model));
        }
Exemple #2
0
        public ActionResult EditUser(ManageUsersEditModel model)
        {
            pageResourceManager.InsertTitlePart("后台管理-编辑用户资料");
            if (!authorizer.User_Manage(model.UserId))
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "您没有权限修改此用户")));
            }

            string mess   = "";
            bool   result = ValidateEmail(model.AccountEmail, model.UserId, out mess);

            if (!result)
            {
                return(Json(new StatusMessageData(StatusMessageType.Hint, WebUtility.HtmlDecode(mess))));
                //ViewData["statusMessageData"] = new StatusMessageData(StatusMessageType.Error, WebUtility.HtmlDecode(mess));
                //return View(model);
            }

            //判断管理员是否解除了编辑用户的管制状态
            if (model.Moderated == 0)
            {
                User editedUser = userService.GetFullUser(model.UserId);
                if (editedUser != null && editedUser.IsModerated)
                {
                    userService.NoModeratedUser(model.UserId);
                }
            }
            User        user    = model.AsUserForEditUser();
            UserProfile profile = user.Profile;

            profile.Mobile = model.Mobile ?? string.Empty;
            new UserProfileService().Update(profile);

            iMembershipService.UpdateUser(user);

            return(Json(new StatusMessageData(StatusMessageType.Success, "修改用户资料成功")));
        }