Esempio n. 1
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));
        }
Esempio n. 2
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());
        }
Esempio n. 3
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();
        }