// GET: AtelierDepartments
        public async Task <IActionResult> Index([FromQuery] int page = 1)
        {
            page--;
            var cnt = _context.AtelierDepartments.Count();

            return(View(new DataViewModel <AtelierDepartment>()
            {
                Data = _cachedService.GetAtelierDepartments().Skip(page * _pSize).Take(_pSize),
                PageCount = cnt / _pSize + (cnt % _pSize > 0 ? 1 : 0),
                CurrentPage = page
            }));
        }
Пример #2
0
        // GET: AtelierDepartments
        public async Task <IActionResult> Index([FromQuery] int page = 1)
        {
            Func <AtelierDepartment, bool> filter = a => true;

            if (Request.Cookies.ContainsKey("AtelierFilter"))
            {
                var filterValue = Request.Cookies["AtelierFilter"].Trim().ToLower();
                if (!string.IsNullOrWhiteSpace(filterValue))
                {
                    filter = a => a.DepartmentName.ToLower().Contains(filterValue) || a.AmountOfWorkers.ToString().Contains(filterValue) || a.DescriptionOfTheTypeOfWork.ToLower().Contains(filterValue);
                }
            }
            page--;
            var cnt = _context.AtelierDepartments.Count();

            return(View(new DataViewModel <AtelierDepartment>()
            {
                Data = _cachedService.GetAtelierDepartments().Where(filter).Skip(page * _pSize).Take(_pSize),
                PageCount = cnt / _pSize + (cnt % _pSize > 0 ? 1 : 0),
                CurrentPage = page
            }));
        }
        // GET: Employees/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var employee = _cachedService.GetEmployees().FirstOrDefault(m => m.IdEmployee == id);

            if (employee == null)
            {
                return(NotFound());
            }
            ViewData["DepartmentId"] = new SelectList(_cachedService.GetAtelierDepartments(), "IdDepartment", "DepartmentName", employee.DepartmentId);
            return(View(employee));
        }