• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ManageUserViewModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ManageUserViewModel的典型用法代码示例。如果您正苦于以下问题:C# ManageUserViewModel类的具体用法?C# ManageUserViewModel怎么用?C# ManageUserViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ManageUserViewModel类属于命名空间,在下文中一共展示了ManageUserViewModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ManageData

        public void ManageData(string userId, ManageUserViewModel user)
        {
            var userFromDb = this.Data.Users
                .GetById(userId);

            userFromDb.FirstName = user.FirstName;
            userFromDb.SecondName = user.SecondName;
            userFromDb.LastName = user.LastName;
            userFromDb.Gender = user.Gender;
            userFromDb.Age = user.Age;
            userFromDb.Town = user.Town;
            userFromDb.Country = user.Country;
            userFromDb.Website = user.Website;

            this.Data.Users.SaveChanges();
        }
开发者ID:Nikolay-D,项目名称:Customer-Relationship-Management,代码行数:16,代码来源:ManageUserServices.cs


示例2: aj_MasterPasswordUpdate

        public async Task<string> aj_MasterPasswordUpdate(ManageUserViewModel md)
        {
            ResultInfo rAjaxResult = new ResultInfo();
            try
            {
                if (ModelState.IsValid)
                {
                    IdentityResult result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), md.OldPassword, md.NewPassword);

                    if (result.Succeeded)
                    {
                        rAjaxResult.result = true;
                    }
                    else
                    {
                        rAjaxResult.message = String.Join(":", result.Errors);
                        rAjaxResult.result = false;
                    }
                }
                else
                {
                    List<string> errMessage = new List<string>();
                    foreach (ModelState modelState in ModelState.Values)
                        foreach (ModelError error in modelState.Errors)
                            errMessage.Add(error.ErrorMessage);

                    rAjaxResult.message = String.Join(":", errMessage);
                    rAjaxResult.result = false;
                }
            }
            catch (Exception ex)
            {
                rAjaxResult.result = false;
                rAjaxResult.message = ex.Message;
            }

            return defJSON(rAjaxResult);

        }
开发者ID:jcincloud,项目名称:C431505_Mami520,代码行数:39,代码来源:UsersController.cs


示例3: Manage

        public async Task<IActionResult> Manage(ManageUserViewModel model)
        {
            ViewBag.ReturnUrl = Url.Action("Manage");
            if (ModelState.IsValid)
            {
                var user = await GetCurrentUserAsync();
                var result = await UserManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword);
                if (result.Succeeded)
                {
                    return RedirectToAction("Manage", new { Message = ManageMessageId.ChangePasswordSuccess });
                }
                else
                {
                    AddErrors(result);
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:curtismj1,项目名称:.netWebsite,代码行数:20,代码来源:AccountController.cs


示例4: Manage

        public async Task<ActionResult> Manage(ManageUserViewModel model)
        {
            bool hasPassword = HasPassword();
            ViewBag.HasLocalPassword = hasPassword;
            ViewBag.ReturnUrl = Url.Action("Manage");
            if (hasPassword)
            {
                if (ModelState.IsValid)
                {
                    IdentityResult result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword);
                    if (result.Succeeded)
                    {
                        return RedirectToAction("Manage", new { Message = ManageMessageId.ChangePasswordSuccess });
                    }
                    else
                    {
                        AddErrors(result);
                    }
                }
            }
            else
            {
                // User does not have a password so remove any validation errors caused by a missing OldPassword field
                ModelState state = ModelState["OldPassword"];
                if (state != null)
                {
                    state.Errors.Clear();
                }

                if (ModelState.IsValid)
                {
                    IdentityResult result = await UserManager.AddPasswordAsync(User.Identity.GetUserId(), model.NewPassword);
                    if (result.Succeeded)
                    {
                        return RedirectToAction("Manage", new { Message = ManageMessageId.SetPasswordSuccess });
                    }
                    else
                    {
                        AddErrors(result);
                    }
                }
            }

            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return View(model);
        }
开发者ID:NeverlandForKi,项目名称:YueSao,代码行数:46,代码来源:AccountController.cs


示例5: Manage

        public async Task<ActionResult> Manage(ManageUserViewModel model)
        {
            bool hasPassword = HasPassword();
            ViewBag.HasLocalPassword = hasPassword;
            ViewBag.ReturnUrl = Url.Action("Manage");
            if (hasPassword)
            {
                if (ModelState.IsValid)
                {
                    IdentityResult result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword);
                    if (result.Succeeded)
                    {
                        return RedirectToAction("Manage", new { Message = ManageMessageId.ChangePasswordSuccess });
                    }
                    else
                    {
                        AddErrors(result);
                    }
                }
            }
            else
            {
                // User does not have a password so remove any validation errors caused by a missing OldPassword field
                ModelState state = ModelState["OldPassword"];
                if (state != null)
                {
                    state.Errors.Clear();
                }

                if (ModelState.IsValid)
                {
                    IdentityResult result = await UserManager.AddPasswordAsync(User.Identity.GetUserId(), model.NewPassword);
                    if (result.Succeeded)
                    {
                        return RedirectToAction("Manage", new { Message = ManageMessageId.SetPasswordSuccess });
                    }
                    else
                    {
                        AddErrors(result);
                    }
                }
            }

            ViewBag.menuItemActive = "Compte";
            // Si nous sommes arrivés là, un échec s’est produit. Réafficher le formulaire
            return View();
        }
开发者ID:fuhrmanator,项目名称:gti792-peets,代码行数:47,代码来源:AccountController.cs


示例6: ManageProfile

        public async Task<ActionResult> ManageProfile(ManageUserViewModel model)
        {
            ViewBag.ReturnUrl = Url.Action("Manage");
            ModelState.Remove("OldPassword");
            ModelState.Remove("NewPassword");
            ModelState.Remove("ConfirmPassword");
            if (ModelState.IsValid)
            {
                ApplicationUser appUserModel = UserManager.FindById(User.Identity.GetUserId());
                appUserModel.Email = model.Email;
                appUserModel.MobileNo = model.MobileNo;
                appUserModel.UserName = model.MobileNo;
                IdentityResult result = await UserManager.UpdateAsync(appUserModel);

                if (result.Succeeded)
                {
                    return RedirectToAction("Manage", new { Message = ManageMessageId.ProfileChangedSuccess });

                }
                else
                {
                    AddErrors(result);
                }
            }


            // If we got this far, something failed, redisplay form
            return View("Manage", model);
        }
开发者ID:tmccord123,项目名称:TMCDev,代码行数:29,代码来源:AccountController.cs


示例7: Manage

 //
 // GET: /Account/Manage
 public ActionResult Manage(ManageMessageId? message)
 {
     ViewBag.StatusMessage =
         message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
         : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
         : message == ManageMessageId.RemoveLoginSuccess ? "The external login was removed."
         : message == ManageMessageId.ProfileChangedSuccess ? "Profile changed successfully."
         : message == ManageMessageId.Error ? "An error has occurred."
         : "";
     ViewBag.HasLocalPassword = HasPassword();
     ApplicationUser appUserModel = UserManager.FindById(User.Identity.GetUserId());
     ManageUserViewModel manageUserViewModel = new ManageUserViewModel();
     manageUserViewModel.Email = appUserModel.Email;
     manageUserViewModel.MobileNo = appUserModel.MobileNo;
     ViewBag.ReturnUrl = Url.Action("Manage");
     return View(manageUserViewModel);
 }
开发者ID:tmccord123,项目名称:TMCDev,代码行数:19,代码来源:AccountController.cs


示例8: Manage

        public async Task<ActionResult> Manage(ManageUserViewModel model)
        {
            bool hasPassword = HasPassword();
            ViewBag.HasLocalPassword = hasPassword;
            ViewBag.ReturnUrl = Url.Action("Manage");
            if (hasPassword)
            {
                if (ModelState.IsValid)
                {
                    IdentityResult result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword);
                    if (result.Succeeded)
                    {
                        var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
                        await SignInAsync(user, isPersistent: false);
                        return RedirectToAction("Manage", new { Message = ManageMessageId.ChangePasswordSuccess });
                    }
                    else
                    {
                        AddErrors(result);
                    }
                }
            }
            else
            {
                // Для пользователя не указан пароль, поэтому все ошибки проверки из-за отсутствия поля OldPassword будут удалены
                ModelState state = ModelState["OldPassword"];
                if (state != null)
                {
                    state.Errors.Clear();
                }

                if (ModelState.IsValid)
                {
                    IdentityResult result = await UserManager.AddPasswordAsync(User.Identity.GetUserId(), model.NewPassword);
                    if (result.Succeeded)
                    {
                        return RedirectToAction("Manage", new { Message = ManageMessageId.SetPasswordSuccess });
                    }
                    else
                    {
                        AddErrors(result);
                    }
                }
            }

            // Появление этого сообщения означает наличие ошибки; повторное отображение формы
            return View(model);
        }
开发者ID:Bogomazz,项目名称:TDMVC,代码行数:48,代码来源:AccountController.cs


示例9: Manage

        public async Task<ActionResult> Manage(ManageUserViewModel model)
        {
            string userId = User.Identity.GetUserId();
            string localUserName = await Logins.GetProviderKey(User.Identity.GetUserId(), IdentityConfig.LocalLoginProvider);
            bool hasLocalLogin = localUserName != null;
            ViewBag.HasLocalPassword = hasLocalLogin;
            ViewBag.ReturnUrl = Url.Action("Manage");
            if (hasLocalLogin)
            {               
                if (ModelState.IsValid)
                {
                    bool changePasswordSucceeded = await ChangePassword(localUserName, model.OldPassword, model.NewPassword);
                    if (changePasswordSucceeded)
                    {
                        return RedirectToAction("Manage", new { Message = ManageMessageId.ChangePasswordSuccess });
                    }
                    else
                    {
                        ModelState.AddModelError(String.Empty, "The current password is incorrect or the new password is invalid.");
                    }
                }
            }
            else
            {
                // User does not have a local password so remove any validation errors caused by a missing OldPassword field
                ModelState state = ModelState["OldPassword"];
                if (state != null)
                {
                    state.Errors.Clear();
                }

                if (ModelState.IsValid)
                {
                    try
                    {
                        // Create the local login info and link the local account to the user
                        localUserName = User.Identity.GetUserName();
                        if (await Secrets.Create(new UserSecret(localUserName, model.NewPassword)) &&
                            await Logins.Add(new UserLogin(userId, IdentityConfig.LocalLoginProvider, localUserName)))
                        {
                            return RedirectToAction("Manage", new { Message = ManageMessageId.SetPasswordSuccess });
                        }
                        else
                        {
                            ModelState.AddModelError(String.Empty, "Failed to set password");
                        }
                    }
                    catch (Exception e)
                    {
                        ModelState.AddModelError(String.Empty, e);
                    }
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:aleksandrzak-rafal,项目名称:AdaptiveCode,代码行数:57,代码来源:TaskController.cs


示例10: Manage

 public async Task<ActionResult> Manage()
 {
     var viewModel = new ManageUserViewModel();
     using (var db = new DatabaseContext())
     {
         var userId = User.Identity.GetUserId();
         var user = await db.Users.Where(x => x.Id == userId).SingleOrDefaultAsync();
         if (user.SlackToken != null)
         {
             var userRaw = new WebClient().DownloadString($"https://slack.com/api/auth.test?token={user.SlackToken}");
             var userResp = JsonConvert.DeserializeAnonymousType(userRaw, new { user = "" });
             viewModel.SlackUsername = userResp.user;
         }
         return View("Manage", viewModel);
     }
 }
开发者ID:Quantumplation,项目名称:Various.Services,代码行数:16,代码来源:UserController.cs


示例11: BanUser

 public async Task<JsonResult> BanUser(ManageUserViewModel model)
 {
     var context = new PhotoContestDbContext();
     var store = new UserStore<User>(context);
     var manager = new UserManager<User>(store);
     await manager.SetLockoutEnabledAsync(model.Id, true);
     await manager.SetLockoutEndDateAsync(model.Id, DateTime.Now.AddDays(14));
     return this.Json(
         string.Format("Successfully locked user {0}", model.UserName),
         JsonRequestBehavior.AllowGet);
 }
开发者ID:ASP-TEAM,项目名称:Photo-Contest-Project,代码行数:11,代码来源:AdminController.cs


示例12: Manage

        public async Task<ActionResult> Manage(ManageUserViewModel model)
        {
            ViewBag.HasLocalPassword = false;
            ViewBag.ReturnUrl = Url.Action("Manage");

            return View(model);
        }
开发者ID:modulexcite,项目名称:Fooidity,代码行数:7,代码来源:AccountController.cs


示例13: Manage

        public async Task<ActionResult> Manage(ManageUserViewModel model)
        {
            string userId = User.Identity.GetUserId();
            bool hasLocalLogin = await IdentityManager.Logins.HasLocalLoginAsync(userId);
            ViewBag.HasLocalPassword = hasLocalLogin;
            ViewBag.ReturnUrl = Url.Action("Manage");
            if (hasLocalLogin)
            {               
                if (ModelState.IsValid)
                {
                    IdentityResult result = await IdentityManager.Passwords.ChangePasswordAsync(User.Identity.GetUserName(), model.OldPassword, model.NewPassword);
                    if (result.Success)
                    {
                        return RedirectToAction("Manage", new { Message = "Your password has been changed." });
                    }
                    else
                    {
                        AddErrors(result);
                    }
                }
            }
            else
            {
                // User does not have a local password so remove any validation errors caused by a missing OldPassword field
                ModelState state = ModelState["OldPassword"];
                if (state != null)
                {
                    state.Errors.Clear();
                }

                if (ModelState.IsValid)
                {
                    // Create the local login info and link it to the user
                    IdentityResult result = await IdentityManager.Logins.AddLocalLoginAsync(userId, User.Identity.GetUserName(), model.NewPassword);
                    if (result.Success)
                    {
                        return RedirectToAction("Manage", new { Message = "Your password has been set." });
                    }
                    else
                    {
                        AddErrors(result);
                    }
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:HansS,项目名称:TelerikAcademy-homework,代码行数:48,代码来源:AccountController.cs


示例14: aj_MasterPasswordUpdate

        public async Task<string> aj_MasterPasswordUpdate(ManageUserViewModel md)
        {
            ResultInfo rAjaxResult = new ResultInfo();
            try
            {
                if (ModelState.IsValid)
                {
                    if (this.LoginUserFlag == "Y")
                    {
                        if (md.ConfirmPassword != md.NewPassword)
                        {
                            rAjaxResult.message = Resources.Res.Log_Err_NewPasswordNotSure;
                            rAjaxResult.result = false;
                            return defJSON(rAjaxResult);
                        }
                        if (md.OldPassword == md.NewPassword)
                        {
                            rAjaxResult.message = Resources.Res.Log_Err_NewPasswordSame;
                            rAjaxResult.result = false;
                            return defJSON(rAjaxResult);
                        }
                        using (var db0 = getDB0())
                        {
                            var getUser = db0.Sales.Find(this.UserId);
                            if (md.OldPassword != EncryptString.desDecryptBase64(HttpUtility.UrlDecode(getUser.password)))
                            {
                                rAjaxResult.message = Resources.Res.Log_Err_Password;
                                rAjaxResult.result = false;
                                return defJSON(rAjaxResult);
                            }
                            else {
                                getUser.password= HttpUtility.UrlEncode(EncryptString.desEncryptBase64(md.NewPassword));
                                db0.SaveChanges();
                            }
                        }
                    }
                    else if (this.LoginUserFlag == "N")
                    {
                        IdentityResult result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), md.OldPassword, md.NewPassword);

                        if (result.Succeeded)
                        {
                            rAjaxResult.result = true;
                        }
                        else
                        {
                            rAjaxResult.message = String.Join(":", result.Errors);
                            rAjaxResult.result = false;
                        }
                    }

                }
                else
                {
                    List<string> errMessage = new List<string>();
                    foreach (ModelState modelState in ModelState.Values)
                        foreach (ModelError error in modelState.Errors)
                            errMessage.Add(error.ErrorMessage);

                    rAjaxResult.message = String.Join(":", errMessage);
                    rAjaxResult.result = false;
                }
            }
            catch (Exception ex)
            {
                rAjaxResult.result = false;
                rAjaxResult.message = ex.Message;
            }

            return defJSON(rAjaxResult);

        }
开发者ID:jcingroup,项目名称:C131507_1komo,代码行数:72,代码来源:UsersController.cs


示例15: Manage

        public async Task<ActionResult> Manage(ManageUserViewModel model)
        {
            bool hasPassword = HasPassword();
            ViewBag.HasLocalPassword = hasPassword;
            ViewBag.HasAvatar = CurrentUser.AvatarURL != null;
            ViewBag.ReturnUrl = Url.Action("Manage");
            if (hasPassword)
            {
                if (ModelState.IsValid)
                {
                    IdentityResult result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword);
                    if (result.Succeeded)
                    {
                        return RedirectToAction("Manage", new { Message = ManageMessageId.ChangePasswordSuccess });
                    }
                    else
                    {
                        AddErrors(result);
                    }
                }
            }
            else
            {
                // User does not have a password so remove any validation errors caused by a missing OldPassword field
                ModelState state = ModelState["OldPassword"];
                if (state != null)
                {
                    state.Errors.Clear();
                }

                if (ModelState.IsValid)
                {
                    IdentityResult result = await UserManager.AddPasswordAsync(User.Identity.GetUserId(), model.NewPassword);
                    if (result.Succeeded)
                    {
                        return RedirectToAction("Manage", new { Message = ManageMessageId.SetPasswordSuccess });
                    }
                    else
                    {
                        AddErrors(result);
                    }
                }
            }

            // Появление этого сообщения означает наличие ошибки; повторное отображение формы
            return View(model);
        }
开发者ID:BreakTheScilence,项目名称:OnlineShopTime,代码行数:47,代码来源:AccountController.cs



注:本文中的ManageUserViewModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ManagedCallbackType类代码示例发布时间:2022-05-24
下一篇:
C# ManageMessageId类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap