private IQueryable <User> ApplyQueryParameters(domain.ISearchQueryUser searchQuery, IQueryable <User> query)
        {
            if (searchQuery.UnitId.HasValue)
            {
                query = query.Where(x => x.UnitId == searchQuery.UnitId.Value);
            }

            return(query);
        }
        public async Task <IList <domain.IUser> > Search(domain.ISearchQueryUser searchQuery)
        {
            using (var context = await _dbCommonContextFactory.CreateDbContext())
            {
                var query = context.Users.Where(x => !x.IsDeleted);
                query = ApplyQueryParameters(searchQuery, query);

                var users = query
                            .OrderBy(x => x.UserId)
                            .Skip(searchQuery.Skip ?? SearchConstants.DEFAULT_SKIP)
                            .Take(searchQuery.Take ?? SearchConstants.DEFAULT_TAKE)
                            .ToList();

                await AttachPropertiesFromEmployeePermissions(users);

                return(users.ToList <domain.IUser>());
            }
        }