Ejemplo n.º 1
0
        public async Task OnGetAsync(string returnUrl = null)
        {
            ReturnUrl = returnUrl;
            var availableTowns = await Town4UserSpecification.CreateAsync(HttpContext.User, _userManager);

            var townlist = await _townService.ListAsync(availableTowns);

            ViewData["TownList"] = new SelectList(townlist, "Id", "Name");

            var availableGroups = await Group4UserSpecification.CreateAsync(HttpContext.User, _userManager);

            var groups = await _groupService.ListAsync(availableGroups);

            ViewData["GroupList"] = new SelectList(groups, "Id", "Name");
            var user = await _userManager.GetUserAsync(HttpContext.User);

            var roleList = new List <VehicleRole>();

            if (await _userManager.IsInRoleAsync(user, "GlobalVisitor") ||
                await _userManager.IsInRoleAsync(user, "Admins"))
            {
                roleList.Add(new VehicleRole()
                {
                    Name = "TownManager", LocalName = "街道管理员"
                });
            }
            roleList.Add(new VehicleRole()
            {
                Name = "GroupManager", LocalName = "安全组管理员"
            });
            ViewData["RoleList"] = new SelectList(roleList, "Name", "LocalName");
        }