Exemplo n.º 1
0
 public override async Task <List <DAL.App.DTO.ProductForClient> > AllAsync()
 {
     return(await RepositoryDbSet
            .Include(p => p.Product)
            .ThenInclude(p => p.ProductName)
            .ThenInclude(t => t.Translations)
            .Include(p => p.Client)
            .Include(p => p.ProductServices)
            .ThenInclude(p => p.Description)
            .ThenInclude(p => p.Translations)
            .Select(e => ProductForClientMapper.MapFromDomain(e))
            .ToListAsync());
 }
Exemplo n.º 2
0
        public override async Task <DAL.App.DTO.ProductForClient> FindAsync(params object[] id)
        {
            var culture = Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2).ToLower();

            var productForClient = await RepositoryDbSet.FindAsync(id);

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

                await RepositoryDbContext.Entry(productForClient)
                .Reference(c => c.Product)
                .LoadAsync();

                await RepositoryDbContext.Entry(productForClient.Product)
                .Reference(c => c.ProductName)
                .LoadAsync();

                await RepositoryDbContext.Entry(productForClient.Product.ProductName)
                .Collection(c => c.Translations)
                .Query()
                .Where(t => t.Culture == culture)
                .LoadAsync();

                await RepositoryDbContext.Entry(productForClient)
                .Collection(c => c.ProductServices)
                .LoadAsync();

                foreach (var service in productForClient.ProductServices)
                {
                    await RepositoryDbContext.Entry(service)
                    .Reference(c => c.Description)
                    .LoadAsync();

                    await RepositoryDbContext.Entry(service.Description)
                    .Collection(c => c.Translations)
                    .Query()
                    .Where(t => t.Culture == culture)
                    .LoadAsync();
                }
            }

            return(ProductForClientMapper.MapFromDomain(productForClient));
        }
Exemplo n.º 3
0
 public async Task <List <ProductForClient> > AllForClientAsync(int?clientId)
 {
     return((await Uow.ProductsForClients.AllForClientAsync(clientId))
            .Select(e => ProductForClientMapper.MapFromDAL(e))
            .ToList());
 }