Beispiel #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");
        }
Beispiel #2
0
        public async Task <List <TownItem> > GetAvailableTownsEagerAsync(ClaimsPrincipal user)
        {
            Town4UserSpecification canFetch = await Town4UserSpecification.CreateAsync(user, _userManager);

            canFetch.Includes.Add(t => t.Drivers);
            canFetch.Includes.Add(t => t.Groups);
            canFetch.Includes.Add(t => t.Vehicles);

            return(await _townRepository.ListAsync(canFetch));
        }
Beispiel #3
0
        public async Task <IActionResult> OnGetAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            DistrictItem = await _context.Districts.SingleOrDefaultAsync(m => m.Id == id);

            if (DistrictItem == null)
            {
                return(NotFound());
            }
            var specification = await Town4UserSpecification.CreateAsync(HttpContext.User, _userManager);

            specification.Includes.Add(t => t.Drivers);
            specification.Includes.Add(t => t.Vehicles);
            specification.Includes.Add(t => t.Groups);

            var towns = await _townRepository.ListAsync(specification);

            Towns = towns.OrderBy(t => t.Code).Select(t =>
                                                      new TownListViewModel()
            {
                Id           = t.Id,
                Code         = t.Code,
                Name         = t.Name,
                GroupCount   = t.Groups?.Count ?? 0,
                DriverCount  = t.Drivers?.Count ?? 0,
                VehicleCount = t.Vehicles?.Count ?? 0,
                IsValid      = t.IsValid(),
                StatusText   = t.IsValid() ? "正常" : "预警",
            }).ToList();

            UserFiles = _context.Files.Where(t => t.Visibility == VisibilityType.Global).Select(t => new UserFileListViewModel(t)).ToList();

            return(Page());
        }
Beispiel #4
0
        public async Task OnGetAsync()
        {
            var specification = await Town4UserSpecification.CreateAsync(HttpContext.User, _userManager);

            specification.Includes.Add(t => t.Drivers);
            specification.Includes.Add(t => t.Vehicles);
            specification.Includes.Add(t => t.Groups);

            var towns = await _townRepository.ListAsync(specification);

            TownList = towns.OrderBy(t => t.Code).Select(t =>
                                                         new TownListViewModel()
            {
                Id           = t.Id,
                Code         = t.Code,
                Name         = t.Name,
                GroupCount   = t.Groups?.Count ?? 0,
                DriverCount  = t.Drivers?.Count ?? 0,
                VehicleCount = t.Vehicles?.Count ?? 0,
                IsValid      = t.IsValid(),
                StatusText   = t.IsValid() ? "正常" : "预警",
            }).ToList();
        }