public async Task <IActionResult> ShowAll(int?visitorId, CommonListQuery options = null)
        {
            var query = visitorId == null?passRepository.GetAll() : passRepository.GetAll()
                            .Where(v => v.VisitorId == visitorId);

            var passes = Task.Run(() => new PagesDividedList <ShootingPermission>(query
                                                                                  .Include(v => v.StationFacilities)
                                                                                  .Include(v => v.ShootingPermissionIssued)
                                                                                  .ThenInclude(v => v.Department)
                                                                                  .SearchByMember(options.SearchСolumn, options.SearchValue)
                                                                                  .OrderByMember("Id", true), options.CurrentPage, options.PageSize));

            var TemporaryPasses = await passes;

            if (visitorId != 0)
            {
                ViewBag.CurrentPage = "all-ShootingPermission";
            }
            return(View(new ShootingPermissionVM
            {
                ShootingPermissions = await passes,
                PurposeVisitorId = visitorId,
                ShowAdvancedFeatures = HttpContext.User.IsInRole("Administrator") || HttpContext.User.IsInRole("Moderator")
            }));
        }
        public async Task <IActionResult> StationFacilityExtension(CommonListQuery options = null)
        {
            var passes = await Task.Run(() => new PagesDividedList <StationFacility>(stationFacilityRep.GetAll()
                                                                                     .SearchByMember(options.SearchСolumn, options.SearchValue)
                                                                                     .OrderByMember("Id", true), options.CurrentPage, options.PageSize));

            return(View());
        }
예제 #3
0
 public IActionResult Index(CommonListQuery commonListQuery)
 {
     new RandomDataGenerator(dBContext, userManager, roleManager);
     ViewBag.CurrentPage = "all-HomeController";
     return(View(new MainPageVM(_visitorsRepository, commonListQuery)
     {
         ShowAdvancedFeatures = HttpContext.User.IsInRole("Administrator") || HttpContext.User.IsInRole("Moderator")
     }));
 }
예제 #4
0
        public async Task <IActionResult> ShowOneItemData(string oneItemTypeName, CommonListQuery options, int selectedId)
        {
            if (nameAndActionPairs.ContainsKey(oneItemTypeName))
            {
                var query       = nameAndActionPairs[oneItemTypeName].GetAll;
                var dividedList = await Task.Run(() => new PagesDividedList <IOneValueCommon>(query, options.CurrentPage, options.PageSize));

                if (!dividedList.Items.Where(v => v.Id == selectedId).Any() && selectedId != 0)
                {
                    dividedList.Items.Add(nameAndActionPairs[oneItemTypeName].GetAll
                                          .Where(v => v.Id == selectedId).First());
                }
                return(View(new OneItemDataVM {
                    OneValues = dividedList, Options = options,
                    ExtendMenuHeader = nameAndActionPairs[oneItemTypeName].OneValueName, SelectedItem = selectedId
                }));
            }
            return(BadRequest());
        }
예제 #5
0
        public async Task <IActionResult> ShowAll(CommonListQuery options = null)
        {
            var PagesDividedQuery = Task.Run(() => new PagesDividedList <AppUser>(userManager.Users
                                                                                  .SearchByMember(options.SearchСolumn, options.SearchValue)
                                                                                  .OrderByMember("Id", true), options.CurrentPage, options.PageSize));

            var users = await PagesDividedQuery;

            ViewBag.CurrentPage = "all-User";
            var userEmployeePairs = users.Items.Select(u => new
            {
                employee = employeeRepository
                           .GetAll()
                           .Where(e => u.EmployeeId == e.Id)
                           .Include(v => v.Department)
                           .First(),
                user = u
            })
                                    .ToDictionary(k => k.user, v => v.employee);

            return(View(new UserVM {
                userEmployeePairs = userEmployeePairs, PageDividorInfo = users.PageDividorInfo
            }));
        }