Exemplo n.º 1
0
        public async Task <PagedResultDto <EmployeeListDto> > GetAllEmployees(GetAllEmployeeInput input)
        {
            var filteredEmployees = _employeeRepository.GetAllIncluding(e => e.Nationality).AsNoTracking()
                                    .WhereIf(!string.IsNullOrWhiteSpace(input.Filter),
                                             e => e.FullName.StringValue.ToLower().Contains(input.Filter.ToLower().Trim()) ||
                                             !string.IsNullOrEmpty(e.Code) && e.Code.ToLower().Trim().Contains(input.Filter.ToLower().Trim()));

            var query = from employee in filteredEmployees
                        join branch in _branchRepository.GetAll().AsNoTracking() on employee.BranchId equals branch.Id into branches
                        from branch in branches.DefaultIfEmpty()

                        select new EmployeeListDto
            {
                Id          = employee.Id,
                FullName    = employee.FullName.CurrentCultureText,
                Email       = employee.Email,
                DateOfBirth = employee.DateOfBirth,
                PhoneNumber = employee.PhoneNumber,
                BranchName  = branch == null ? "" : branch.Name.CurrentCultureText,
                NationalId  = employee.NationalId,
                Code        = employee.Code,
                IsActive    = employee.IsActive,
                Nationality = employee.Nationality != null? employee.Nationality.Nationality.CurrentCultureText : ""
            };
            var totalCount = await query.CountAsync();

            var employees = await query.OrderBy(input.Sorting ?? "id desc").PageBy(input).ToListAsync();

            return(new PagedResultDto <EmployeeListDto>(totalCount, employees));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Index(GetAllEmployeeInput input)
        {
            var output = await _employeeService.GetAll(input);

            var model = new IndexViewModel(output.Items);

            return(View(model));
        }
Exemplo n.º 3
0
        public async Task <ListResultDto <EmployeeListDto> > GetAll(GetAllEmployeeInput input)
        {
            var tasks = await _taskRepository
                        .GetAll()
                        .WhereIf(input.Handle.HasValue, t => t.Handle == input.Handle.Value)
                        .OrderByDescending(t => t.CreationTime)
                        .ToListAsync();

            return(new ListResultDto <EmployeeListDto>(
                       ObjectMapper.Map <List <EmployeeListDto> >(tasks)
                       ));
        }