public void AdminUserManagerTest() { var controller = new AdminUserManager(_mock.Object); Assert.IsNotNull(controller); Assert.IsInstanceOfType(controller, typeof(AdminUserManager)); }
/// <summary> /// Constructor method. /// </summary> public AccountController(AdminUserManager adminUserManager, AdminSignInManager adminSignInManager, IAuthenticationManager authenticationManager, IEmailDispatcherService emailDispatcherService) { _adminUserManager = adminUserManager ?? throw new ArgumentNullException(nameof(adminUserManager), nameof(AccountController)); _adminSignInManager = adminSignInManager ?? throw new ArgumentNullException(nameof(adminSignInManager), nameof(AccountController)); _authenticationManager = authenticationManager ?? throw new ArgumentNullException(nameof(authenticationManager), nameof(AccountController)); _emailDispatcherService = emailDispatcherService ?? throw new ArgumentNullException(nameof(emailDispatcherService), nameof(AccountController)); }
public AdminUserService(AdminUserManager userManager, IRepository <UserRole> userRoleRepository, IRepository <AdminUser> repository) : base(repository) { _userManager = userManager; _userRoleRepository = userRoleRepository; }
public ActionResult AddAdminUser(AdminUserVM model) { AdminUser entity = new AdminUser(); entity.EMail = model.EMail.ToLower(); entity.Password = model.Password; AdminUserManager.AddAdminUser(entity); return(View()); }
public ActionResult Index() { AdminUserViewModel viewModel = new AdminUserViewModel(); try { AdminRoleManager roleManager = new AdminRoleManager(); viewModel.AllRoles = roleManager.GetAllRoles(); AdminUserManager adminManager = new AdminUserManager(); viewModel.AllAdminUsers = adminManager.GetALl(); } catch (Exception ex) { LogService.Log("管理员列表", ex.ToString()); } return View(viewModel); }
public ActionResult AddNewAdmin(AdminUser admin) { try { if (admin != null && admin.Role != 0) { AdminUserManager adminManager = new AdminUserManager(); admin.CreateTime = DateTime.Now; admin.LastUpdatedTime = DateTime.Now; admin.EncryptedPassword = admin.EncryptedPassword.ToMD5(); adminManager.AddAdminUser(admin); } } catch (Exception ex) { LogService.Log("AddNewAdmin", ex.ToString()); } return RedirectToAction("Index"); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new AdminUser { UserName = model.Email, Email = model.Email, CompanyName = model.CompanyName, IsAdmin = true, SubsciptionStatus = "Free Plan" }; var result = await AdminUserManager.CreateAsync(user, model.Password); if (result.Succeeded) { var company = await _companyRepository.CreateCompanyAsync(model.CompanyName); user.CompanyId = company.CompanyId; await AdminUserManager.UpdateAsync(user); result = await AdminUserManager.AddToRoleAsync(user.Id, "Admin"); } if (result.Succeeded) { await AdminSignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Admin")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public JsonResult DeleteResult(string ids) { AjaxResult result=new AjaxResult(); try { if (!string.IsNullOrEmpty(ids)) { AdminUserManager adminManager = new AdminUserManager(); string[] uIds = ids.Split(',').ToArray(); foreach (var id in uIds) { adminManager.deleteAdminUser(id.ToInt32()); } } } catch (Exception ex) { LogService.Log("DeleteResult", ex.ToString()); } return Json(result); }
public AdminUserController(ILogger <AdminQueryController> logger, AdminUserManager manager) { this.logger = logger; this.manager = manager; }
public ActionResult Index() { List <AdminUser> adminusers = AdminUserManager.GetAllAdminUsers(); return(View(adminusers)); }
public ActionResult Login(string username,string password) { var errorMsg = string.Empty; try { AdminUser result = null; if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { AdminUserManager adminManager = new AdminUserManager(); result = adminManager.Login(username, password); if (result != null) { Session[USERINFO] = result; return Redirect("/admin/"); } else { errorMsg = "用户名或密码错误!"; } } else { errorMsg = "用户名密码不可为空!"; } } catch (Exception ex) { LogService.Log("注册用户", ex.ToString()); } ViewBag.Message = errorMsg; return View(); }
public ActionResult UpdateAdmin(AdminUser admin) { try { if (admin != null && admin.AdminId != 0) { AdminUserManager adminManager = new AdminUserManager(); admin.EncryptedPassword = admin.EncryptedPassword.ToMD5(); adminManager.UpdateAdminUser(admin); } } catch (Exception ex) { LogService.Log("UpdateAdmin", ex.ToString()); } return RedirectToAction("Index"); }
/// <summary> /// Constructor method. /// </summary> public ProfileController(AdminUserManager userManager, AdminSignInManager signInManager, IGlobalizationService globalizationService) { _userManager = userManager ?? throw new ArgumentNullException(nameof(userManager), nameof(ProfileController)); _signInManager = signInManager ?? throw new ArgumentNullException(nameof(signInManager), nameof(ProfileController)); _globalizationService = globalizationService ?? throw new ArgumentNullException(nameof(globalizationService), nameof(ProfileController)); }
public AccountController(AdminUserManager userManager, AdminSignInManager signInManager) { UserManager = userManager; SignInManager = signInManager; }