Esempio n. 1
0
        public override async Task <DAL.App.DTO.BillLine> FindAsync(params object[] id)
        {
            var culture = Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2).ToLower();

            var billLine = await RepositoryDbSet.FindAsync(id);

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

                await RepositoryDbContext.Entry(billLine.Bill)
                .Reference(c => c.Comment)
                .LoadAsync();

                await RepositoryDbContext.Entry(billLine.Bill.Comment)
                .Collection(b => b.Translations)
                .Query()
                .Where(t => t.Culture == culture)
                .LoadAsync();

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

                await RepositoryDbContext.Entry(billLine.Product)
                .Collection(b => b.Translations)
                .Query()
                .Where(t => t.Culture == culture)
                .LoadAsync();
            }

            return(BillLineMapper.MapFromDomain(billLine));
        }
Esempio n. 2
0
        public async Task <BillLine> FindForUserAsync(int id, int userId)
        {
            var culture = Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2).ToLower();

            var contact = await RepositoryDbSet
                          .Include(p => p.Product)
                          .ThenInclude(t => t.Translations)
                          .Include(c => c.Bill) //need to include more?
                          .FirstOrDefaultAsync(m => m.Id == id && m.Bill.WorkObject.AppUsersOnObject.Any(p => p.AppUserId == userId));

            return(BillLineMapper.MapFromDomain(contact));
        }
Esempio n. 3
0
        public async Task <List <BillLine> > AllForUserAsync(int userId)
        {
            var culture = Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2).ToLower();

            var res = await RepositoryDbSet
                      .Include(p => p.Bill)
                      .Include(p => p.Product)
                      .ThenInclude(t => t.Translations)
                      .Where(p => p.Bill.WorkObject.AppUsersOnObject.Any(q => q.AppUserId == userId))
                      .Select(e => BillLineMapper.MapFromDomain(e))
                      .ToListAsync();

            return(res);
        }
Esempio n. 4
0
        public override async Task <List <DAL.App.DTO.BillLine> > AllAsync()
        {
            var culture = Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2).ToLower();

            var res = await RepositoryDbSet
                      .Include(p => p.Product)
                      .ThenInclude(t => t.Translations)
                      .Include(p => p.Bill)
                      .ThenInclude(p => p.Comment)
                      .ThenInclude(p => p.Translations)
                      .Select(e => BillLineMapper.MapFromDomain(e))
                      .ToListAsync();

            return(res);
        }