Beispiel #1
0
        public override async Task <Price> FindAsync(params object[] id)
        {
            var price = await RepoDbSet.FindAsync(id);

            if (price != null)
            {
                await RepoDbContext.Entry(price).Reference(p => p.Change).LoadAsync();

                await RepoDbContext.Entry(price).Reference(p => p.Product).LoadAsync();
            }

            return(price);
        }
        public override async Task <ReceiptRow> FindAsync(params object[] id)
        {
            var receiptRow = await RepoDbSet.FindAsync(id);

            if (receiptRow != null)
            {
                await RepoDbContext.Entry(receiptRow).Reference(row => row.Product).LoadAsync();

                await RepoDbContext.Entry(receiptRow).Reference(row => row.Receipt).LoadAsync();
            }

            return(receiptRow);
        }
        public override async Task <ReceiptRowChange> FindAsync(params object[] id)
        {
            var rowChange = await RepoDbSet.FindAsync(id);

            if (rowChange != null)
            {
                await RepoDbContext.Entry(rowChange).Reference(rowC => rowC.Change).LoadAsync();

                await RepoDbContext.Entry(rowChange).Reference(rowC => rowC.ReceiptRow).LoadAsync();
            }

            return(rowChange);
        }
Beispiel #4
0
        public override async Task <LoanRow> FindAsync(params object[] id)
        {
            var loanRow = await RepoDbSet.FindAsync(id);

            if (loanRow != null)
            {
                await RepoDbContext.Entry(loanRow).Reference(l => l.ReceiptRow).LoadAsync();

                await RepoDbContext.Entry(loanRow).Reference(l => l.Loan).LoadAsync();
            }

            return(loanRow);
        }
Beispiel #5
0
        public override async Task <ReceiptParticipant> FindAsync(params object[] id)
        {
            var participant = await RepoDbSet.FindAsync(id);

            if (participant != null)
            {
                await RepoDbContext.Entry(participant).Reference(p => p.AppUser).LoadAsync();

                await RepoDbContext.Entry(participant).Reference(p => p.Receipt).LoadAsync();
            }

            return(participant);
        }
Beispiel #6
0
        public async Task <DALReceiptDTO> FindReceiptAsync(int receiptId)
        {
            var receipt = await RepoDbSet.FindAsync(receiptId);

            if (receipt == null)
            {
                return(null);
            }
            await RepoDbContext.Entry(receipt).Collection(r => r.ReceiptParticipants).LoadAsync();

            await RepoDbContext.Entry(receipt).Reference(r => r.ReceiptManager).LoadAsync();

            return(ReceiptMapper.FromDomain2(receipt));
        }
Beispiel #7
0
        public override async Task <ProductInCategory> FindAsync(params object[] id)
        {
            var productInCategory = await RepoDbSet.FindAsync(id);

            if (productInCategory != null)
            {
                await RepoDbContext.Entry(productInCategory).Reference(obj => obj.Product).LoadAsync();

                await RepoDbContext.Entry(productInCategory).Reference(obj => obj.Category).LoadAsync();

                await RepoDbContext.Entry(productInCategory.Category).Reference(obj => obj.Organization).LoadAsync();
            }

            return(productInCategory);
        }
        public async Task <DALChangeDTO> AddAsync(DALChangeDTO changeDTO)
        {
            var change = ChangeMapper.FromDAL(changeDTO);

            change = (await RepoDbSet.AddAsync(change)).Entity;
            if (change == null)
            {
                return(null);
            }
            await RepoDbContext.Entry(change).Reference(c => c.ChangeName).LoadAsync();

            await RepoDbContext.Entry(change.ChangeName).Collection(c => c.Translations).LoadAsync();

            return(ChangeMapper.FromDomain(change));
        }
Beispiel #9
0
        public override async Task <Loan> FindAsync(params object[] id)
        {
            var loan = await RepoDbSet.FindAsync(id);

            if (loan != null)
            {
                await RepoDbContext.Entry(loan).Reference(l => l.LoanGiver).LoadAsync();

                await RepoDbContext.Entry(loan).Reference(l => l.LoanTaker).LoadAsync();

                await RepoDbContext.Entry(loan).Reference(l => l.ReceiptParticipant).LoadAsync();
            }

            return(loan);
        }
Beispiel #10
0
        public async Task <DALLoanRowDTO> FindAsync(int loanRowId)
        {
            var loanRow = await RepoDbSet.FindAsync(loanRowId);

            if (loanRow == null)
            {
                return(null);
            }

            await RepoDbContext.Entry(loanRow).Reference(l => l.Loan).LoadAsync();

            await RepoDbContext.Entry(loanRow.Loan).Reference(l => l.ReceiptParticipant).LoadAsync();

            await RepoDbContext.Entry(loanRow.Loan.ReceiptParticipant).Reference(l => l.Receipt).LoadAsync();

            return(LoanRowMapper.FromDomain(loanRow));
        }
        public async Task <DALChangeDTO> EditAsync(DALChangeDTO changeDTO)
        {
            var change = await RepoDbSet.FindAsync(changeDTO.Id);

            if (change == null)
            {
                return(null);
            }

            await RepoDbContext.Entry(change).Reference(c => c.ChangeName).LoadAsync();

            await RepoDbContext.Entry(change.ChangeName).Collection(c => c.Translations).LoadAsync();


            change.ChangeName.SetTranslation(changeDTO.Name);

            return(ChangeMapper.FromDomain(change));
        }
        public async Task <DALProductDTO> AddAsync(DALProductDTO dto)
        {
            var product = ProductMapper.FromDAL(dto);

            product = (await RepoDbSet.AddAsync(product)).Entity;
            if (product == null)
            {
                return(null);
            }
            await RepoDbContext.Entry(product).Reference(p => p.ProductName).LoadAsync();

            await RepoDbContext.Entry(product.ProductName).Collection(name => name.Translations).LoadAsync();

            await RepoDbContext.Entry(product).Reference(p => p.ProductDescription).LoadAsync();

            await RepoDbContext.Entry(product.ProductDescription).Collection(desc => desc.Translations).LoadAsync();


            return(ProductMapper.FromDomain(product));
        }
        /// <summary>
        /// Edits products name and description, then returns productDTO
        /// </summary>
        /// <param name="dalProductDTO"></param>
        /// <returns></returns>
        public async Task <DALProductDTO> EditAsync(DALProductDTO dalProductDTO)
        {
            var product = await RepoDbSet.FindAsync(dalProductDTO.Id);

            if (product == null)
            {
                return(null);
            }
            await RepoDbContext.Entry(product).Reference(p => p.ProductName).LoadAsync();

            await RepoDbContext.Entry(product.ProductName).Collection(name => name.Translations).LoadAsync();

            await RepoDbContext.Entry(product).Reference(p => p.ProductDescription).LoadAsync();

            await RepoDbContext.Entry(product.ProductDescription).Collection(desc => desc.Translations).LoadAsync();

            product.ProductDescription.SetTranslation(dalProductDTO.Description);
            product.ProductName.SetTranslation(dalProductDTO.Name);

            return(ProductMapper.FromDomain(product));
        }