예제 #1
0
 public override async Task <List <AppUser> > AllAsync()
 {
     return(await RepositoryDbSet
            .Include(s => s.Shop).ThenInclude(a => a.ShopName).ThenInclude(t => t.Translations)
            .Include(s => s.Shop).ThenInclude(a => a.ShopAddress).ThenInclude(t => t.Translations)
            .Include(s => s.Shop).ThenInclude(a => a.ShopContact).ThenInclude(t => t.Translations)
            .Include(s => s.Shop).ThenInclude(a => a.ShopContact2).ThenInclude(t => t.Translations)
            .Select(e => AppUserMapper.MapFromDomain(e)).ToListAsync());
 }
예제 #2
0
 public async Task <List <DAL.App.DTO.DomainLikeDTO.Identity.AppUser> > GetUserById(int userId)
 {
     return(await RepositoryDbSet
            .Include(s => s.Shop).ThenInclude(a => a.ShopName).ThenInclude(t => t.Translations)
            .Include(s => s.Shop).ThenInclude(a => a.ShopAddress).ThenInclude(t => t.Translations)
            .Include(s => s.Shop).ThenInclude(a => a.ShopContact).ThenInclude(t => t.Translations)
            .Include(s => s.Shop).ThenInclude(a => a.ShopContact2).ThenInclude(t => t.Translations)
            .Where(a => a.Id == userId)
            .Select(e => AppUserMapper.MapFromDomain(e)).ToListAsync());
 }
예제 #3
0
        public override async Task <List <DAL.App.DTO.Identity.AppUser> > AllAsync()
        {
            return(await RepositoryDbSet
//                .Include(c =>c.AppUserOnObjects)
                   .Include(d => d.AppUserInPositions)
                   .ThenInclude(d => d.AppUserPosition)
                   .ThenInclude(d => d.AppUserPositionValue)
                   .ThenInclude(d => d.Translations)
                   .Select(e => AppUserMapper.MapFromDomain(e))
                   .ToListAsync());
        }
예제 #4
0
        public override async Task <AppUser> FindAsync(params object[] id)
        {
            var appUser = await base.FindAsync(id);

            return(AppUserMapper.MapFromDomain(await RepositoryDbSet.Where(a => a.Id == appUser.Id)
                                               .Include(s => s.Shop).ThenInclude(a => a.ShopName).ThenInclude(t => t.Translations)
                                               .Include(s => s.Shop).ThenInclude(a => a.ShopAddress).ThenInclude(t => t.Translations)
                                               .Include(s => s.Shop).ThenInclude(a => a.ShopContact).ThenInclude(t => t.Translations)
                                               .Include(s => s.Shop).ThenInclude(a => a.ShopContact2).ThenInclude(t => t.Translations)
                                               .FirstOrDefaultAsync()));
        }
예제 #5
0
 public async Task <List <AppUser> > AllForUserAsync(int userId)
 {
     return(await RepositoryDbSet
            .Include(c => c.AppUserOnObjects)
            .Include(d => d.AppUserInPositions)
            .ThenInclude(f => f.AppUserPosition)
            .ThenInclude(d => d.AppUserPositionValue)
            .ThenInclude(d => d.Translations)
            .Where(c => c.Id == userId)
            .Select(e => AppUserMapper.MapFromDomain(e))
            .ToListAsync());
 }
예제 #6
0
        public async Task <List <AppUser> > AllAsync(string order, string searchFor)
        {
            var query = RepositoryDbSet
                        .Include(s => s.Shop).ThenInclude(a => a.ShopName).ThenInclude(t => t.Translations)
                        .Include(s => s.Shop).ThenInclude(a => a.ShopAddress).ThenInclude(t => t.Translations)
                        .Include(s => s.Shop).ThenInclude(a => a.ShopContact).ThenInclude(t => t.Translations)
                        .Include(s => s.Shop).ThenInclude(a => a.ShopContact2).ThenInclude(t => t.Translations)
                        .AsQueryable();

            query = Search(query, searchFor);

            var res = await query.Select(e => AppUserMapper.MapFromDomain(e)).ToListAsync();

            return(Order(res, order));
        }
예제 #7
0
        public async Task <List <DAL.App.DTO.DomainLikeDTO.Identity.AppUser> > AllAsyncByShop(int?shopId, string order, string searchFor)
        {
            var query = RepositoryDbSet
                        .Include(s => s.Shop).ThenInclude(a => a.ShopName).ThenInclude(t => t.Translations)
                        .Include(s => s.Shop).ThenInclude(a => a.ShopAddress).ThenInclude(t => t.Translations)
                        .Include(s => s.Shop).ThenInclude(a => a.ShopContact).ThenInclude(t => t.Translations)
                        .Include(s => s.Shop).ThenInclude(a => a.ShopContact2).ThenInclude(t => t.Translations)
                        .Where(a => a.ShopId == shopId || a.ShopId == null)
                        .AsQueryable();

            query = Search(query, searchFor);

            var res = await query.Select(e => AppUserMapper.MapFromDomain(e)).ToListAsync();

            return(Order(res, order));
        }
예제 #8
0
        public override async Task <DAL.App.DTO.Identity.AppUser> FindAsync(params object[] id)
        {
//            return await RepositoryDbSet
//                    .Include(d => d.AppUserInPositions)
//                    .ThenInclude(d => d.AppUserPosition)
//                    .ThenInclude(d => d.AppUserPositionValue)
//                    .ThenInclude(d => d.Translations)
//                    .Select(p => AppUserMapper.MapFromDomain(p))
//                    .FirstOrDefaultAsync(p => p.Id == (int) id[0]);

            var culture = Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2).ToLower();

            var appUser = await RepositoryDbSet.FindAsync(id);

            if (appUser != null)
            {
                await RepositoryDbContext.Entry(appUser)
                .Collection(c => c.AppUserInPositions)
                .LoadAsync();

                foreach (var appUserInPosition in appUser.AppUserInPositions)
                {
                    await RepositoryDbContext.Entry(appUserInPosition)
                    .Reference(c => c.AppUserPosition)
                    .LoadAsync();

                    await RepositoryDbContext.Entry(appUserInPosition.AppUserPosition)
                    .Reference(c => c.AppUserPositionValue)
                    .LoadAsync();

                    await RepositoryDbContext.Entry(appUserInPosition.AppUserPosition.AppUserPositionValue)
                    .Collection(c => c.Translations)
                    .Query()
                    .Where(t => t.Culture == culture)
                    .LoadAsync();
                }
            }

            return(AppUserMapper.MapFromDomain(appUser));
        }