Beispiel #1
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);
        }
        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);
        }
Beispiel #3
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);
        }
        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 #5
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);
        }
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));
        }
        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 #8
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 #9
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);
        }
Beispiel #10
0
        public static string Avatar(string id)
        {
            string imgsrc;
            var    dbContext = new RepoDbContext();
            var    avatar    = dbContext.UserAvatars.SingleOrDefault(x => x.UserId == id);

            if (avatar == null)
            {
                imgsrc = FilePaths.Avatarpath;
            }
            else
            {
                var base64 = Convert.ToBase64String(avatar.Image);
                imgsrc = string.Format(StringFormats.ImageFormat, base64);
            }
            return(imgsrc);
        }
Beispiel #11
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));
        }
 public RepoDbService(RepoDbContext context)
 {
     _context = context;
 }
Beispiel #16
0
 public UserRepo(RepoDbContext context) : base(context)
 {
     _users = context.Users;
 }
Beispiel #17
0
 public UserRepository(RepoDbContext db)
 {
     Db = db;
 }
Beispiel #18
0
 public CompanyRepo(RepoDbContext context) : base(context)
 {
 }
 public ProductRepository(RepoDbContext db)
 {
     Db = db;
 }
Beispiel #20
0
 public ImageRepository(RepoDbContext db)
 {
     Db = db;
 }
Beispiel #21
0
 public CategoryRepository(RepoDbContext db)
 {
     Db = db;
 }
 public GreetingManager(RepoDbContext context)
 {
     _context = context;
 }
Beispiel #23
0
 public BaseRepo(RepoDbContext context)
 {
     _entities = context.Set <TEntity>();
 }
 public UnitOfWork(RepoDbContext dbContext)
 {
     _dbContext  = dbContext;
     CompanyRepo = new CompanyRepo(_dbContext);
     UserRepo    = new UserRepo(_dbContext);
 }