Beispiel #1
0
        public override async Task <DTO.Dog> FindAsync(params object[] id)
        {
            var culture = Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2).ToLower();

            var dog = await RepositoryDbSet.FindAsync(id);

            if (dog != null)
            {
                await RepositoryDbContext.Entry(dog)
                .Reference(c => c.Sex)
                .LoadAsync();

                await RepositoryDbContext.Entry(dog.Sex)
                .Collection(b => b.Translations)
                .Query()
                .Where(t => t.Culture == culture)
                .LoadAsync();

                await RepositoryDbContext.Entry(dog)
                .Reference(c => c.Breed)
                .LoadAsync();

                await RepositoryDbContext.Entry(dog.Breed)
                .Reference(c => c.BreedName)
                .LoadAsync();

                await RepositoryDbContext.Entry(dog.Breed.BreedName)
                .Collection(b => b.Translations)
                .Query()
                .Where(t => t.Culture == culture)
                .LoadAsync();
            }

            return(DogMapper.MapFromDomain(dog));
        }
Beispiel #2
0
 public async Task <List <DAL.App.DTO.Dog> > AllForBreedAsync(int breedId)
 {
     return(await RepositoryDbSet
            .Include(a => a.Breed)
            .Include(a => a.Sex)
            .ThenInclude(a => a.Translations)
            .Where(a => a.BreedId == breedId)
            .Select(e => DogMapper.MapFromDomain(e))
            .ToListAsync());
 }
Beispiel #3
0
 public async Task <Dog> FindForUserAsync(int id, int userId)
 {
     return(DogMapper.MapFromDomain(await RepositoryDbSet
                                    .Include(a => a.Breed)
                                    .ThenInclude(a => a.BreedName)
                                    .ThenInclude(a => a.Translations)
                                    .Include(a => a.Sex)
                                    .ThenInclude(a => a.Translations)
                                    .Include(p => p.AppUser)
                                    .FirstOrDefaultAsync(p => p.Id == id && p.AppUserId == userId)));
 }
Beispiel #4
0
 public override async Task <List <DAL.App.DTO.Dog> > AllAsync()
 {
     return(await RepositoryDbSet
            .Include(a => a.AppUser)
            .Include(m => m.Sex)
            .ThenInclude(t => t.Translations)
            .Include(a => a.Breed)
            .ThenInclude(a => a.BreedName)
            .ThenInclude(t => t.Translations)
            .Select(e => DogMapper.MapFromDomain(e)).ToListAsync());
 }
Beispiel #5
0
        public async Task <List <DAL.App.DTO.Dog> > AllForUserAsync(int userId)
        {
            var culture = Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2).ToLower();

            var resultList = await RepositoryDbSet
                             .Include(a => a.Breed)
                             .ThenInclude(a => a.BreedName)
                             .ThenInclude(a => a.Translations)
                             .Include(a => a.AppUser)
                             .Include(a => a.Sex)
                             .ThenInclude(a => a.Translations)
                             .Where(p => p.AppUserId == userId)
                             .Select(c => DogMapper.MapFromDomain(c))
                             .ToListAsync();



//           var resultList = await RepositoryDbSet
//                .Include(a=> a.Breed)
//                .ThenInclude( a=> a.BreedName)
//                .ThenInclude( a=> a.Translations)
//                .Include(a => a.Sex)
//                .ThenInclude( a=> a.Translations)
//                .Include( a=> a.Owner)
//                .Include( a=> a.DateOfBirth)
//
//
//                .Where( a=> a.AppUserId == userId)
//                .Select(c => DogMapper.MapFromDomain(c))
//                .ToListAsync();
//
//            var res = await RepositoryDbSet
//                .Where(b => b.AppUserId == userId)
//                .Select(c => new
//                {
//                    Id = c.Id,
//                    DogName = c.DogName,
//                    Breed = c.Breed,
//                    Owner = c.Owner,
//                    DateOfBirth = c.DateOfBirth,
//                    DateOfDeath = c.DateOfDeath,
//                    Sex = c.Sex,
//                    Translations = c.Sex.Translations,
//
//                })
//                .ToListAsync();
//
//            var resultList = res.Select(c => new  DTO.Dog()
//            {
//                Id = c.Id,
//                DogName = c.DogName,
//               // Breed = c.Breed,
//                DateOfBirth = c.DateOfBirth,
//                DateOfDeath = c.DateOfDeath,
//                Owner = c.Owner,
//                Sex = c.Sex.Translate(),
//
//
//            }).ToList();
            return(resultList);
        }