Пример #1
0
        public async Task <IEnumerable <OrphanageDataModel.Persons.Orphan> > GetOrphans(int Uid)
        {
            IList <OrphanageDataModel.Persons.Orphan> orphansList = new List <OrphanageDataModel.Persons.Orphan>();

            using (var _orphanageDBC = new OrphanageDbCNoBinary())
            {
                var orphans = await _orphanageDBC.Orphans.AsNoTracking()
                              .Include(o => o.Name)
                              .Include(o => o.Caregiver.Name)
                              .Include(o => o.Caregiver.Address)
                              .Include(o => o.Family.Father.Name)
                              .Include(o => o.Family.Mother.Name)
                              .Include(o => o.Family.PrimaryAddress)
                              .Include(o => o.Family.AlternativeAddress)
                              .Include(o => o.Guarantor.Name)
                              .Where(o => o.UserId == Uid)
                              .ToListAsync();

                foreach (var orphan in orphans)
                {
                    var orphanTofill = orphan;
                    _selfLoopBlocking.BlockOrphanSelfLoop(ref orphanTofill);
                    _uriGenerator.SetOrphanUris(ref orphanTofill);
                    orphansList.Add(orphanTofill);
                }
            }
            return(orphansList);
        }
Пример #2
0
        public async Task <IEnumerable <OrphanageDataModel.Persons.Orphan> > GetOrphans(int Mid)
        {
            IList <OrphanageDataModel.Persons.Orphan> returnedOrphans = new List <OrphanageDataModel.Persons.Orphan>();

            using (var dbContext = new OrphanageDbCNoBinary())
            {
                var orphans = await(from orp in dbContext.Orphans.AsNoTracking()
                                    join fam in dbContext.Families.AsNoTracking() on orp.Family.MotherId equals fam.MotherId
                                    where orp.Family.MotherId == Mid
                                    select orp)
                              .Include(o => o.Education)
                              .Include(o => o.Name)
                              .Include(o => o.Caregiver.Name)
                              .Include(o => o.Caregiver.Address)
                              .Include(o => o.Family.Father.Name)
                              .Include(o => o.Family.Mother.Name)
                              .Include(o => o.Family.Mother.Address)
                              .Include(o => o.Family.PrimaryAddress)
                              .Include(o => o.Family.AlternativeAddress)
                              .Include(o => o.Guarantor.Name)
                              .Include(o => o.Bail)
                              .Include(o => o.HealthStatus)
                              .ToListAsync();
                foreach (var orphan in orphans)
                {
                    var orpToFill = orphan;
                    _selfLoopBlocking.BlockOrphanSelfLoop(ref orpToFill);
                    _uriGenerator.SetOrphanUris(ref orpToFill);
                    returnedOrphans.Add(orpToFill);
                }
            }
            return(returnedOrphans);
        }
Пример #3
0
        public async Task <IEnumerable <OrphanageDataModel.Persons.Orphan> > GetOrphans(int Fid)
        {
            _logger.Information($"Trying to get all orphan those related to the fathers with id ({Fid})");
            IList <OrphanageDataModel.Persons.Orphan> returnedOrphans = new List <OrphanageDataModel.Persons.Orphan>();

            using (var dbContext = new OrphanageDbCNoBinary())
            {
                var orphans = await(from orp in dbContext.Orphans.AsNoTracking()
                                    join fath in dbContext.Families.AsNoTracking() on orp.Family.FatherId equals fath.FatherId
                                    where orp.Family.FatherId == Fid
                                    select orp)
                              .Include(o => o.Education)
                              .Include(o => o.Name)
                              .Include(o => o.Caregiver.Name)
                              .Include(o => o.Caregiver.Address)
                              .Include(o => o.Family.Father.Name)
                              .Include(o => o.Family.Mother.Name)
                              .Include(o => o.Family.PrimaryAddress)
                              .Include(o => o.Family.AlternativeAddress)
                              .Include(o => o.Guarantor.Name)
                              .Include(o => o.Bail)
                              .Include(o => o.HealthStatus)
                              .ToListAsync();
                foreach (var orphan in orphans)
                {
                    var orpToFill = orphan;
                    _selfLoopBlocking.BlockOrphanSelfLoop(ref orpToFill);
                    _uriGenerator.SetOrphanUris(ref orpToFill);
                    returnedOrphans.Add(orpToFill);
                }
            }
            _logger.Information($"father with id({Fid}) has {returnedOrphans.Count} related orphans.");
            return(returnedOrphans);
        }
Пример #4
0
        public async Task <IEnumerable <OrphanageDataModel.Persons.Orphan> > GetOrphans(int Gid)
        {
            _logger.Information($"Trying to get orphans those are related to the guarantor id {Gid}");
            IList <OrphanageDataModel.Persons.Orphan> returnedOrphans = new List <OrphanageDataModel.Persons.Orphan>();

            using (var dbContext = new OrphanageDbCNoBinary())
            {
                var orphans = await(from orp in dbContext.Orphans.AsNoTracking()
                                    join bail in dbContext.Bails.AsNoTracking() on orp.BailId equals bail.Id
                                    join guar in dbContext.Guarantors.AsNoTracking() on bail.GuarantorID equals guar.Id
                                    where guar.Id == Gid
                                    select orp)
                              .Include(o => o.Education)
                              .Include(o => o.Name)
                              .Include(o => o.Caregiver.Name)
                              .Include(o => o.Caregiver.Address)
                              .Include(o => o.Family.Father.Name)
                              .Include(o => o.Family.Mother.Name)
                              .Include(o => o.Family.PrimaryAddress)
                              .Include(o => o.Family.AlternativeAddress)
                              .Include(o => o.Guarantor.Name)
                              .Include(o => o.Bail)
                              .Include(o => o.HealthStatus)
                              .ToListAsync();

                if (orphans != null && orphans.Count > 0)
                {
                    foreach (var orphan in orphans)
                    {
                        var orpToFill = orphan;
                        _selfLoopBlocking.BlockOrphanSelfLoop(ref orpToFill);
                        _uriGenerator.SetOrphanUris(ref orpToFill);
                        returnedOrphans.Add(orpToFill);
                    }
                }
                else
                {
                    _logger.Warning("zero or null orphans records were being got from the database");
                }
            }
            _logger.Information($"{returnedOrphans.Count} records of orphans will be returned");
            return(returnedOrphans);
        }
Пример #5
0
        public async Task <IEnumerable <OrphanageDataModel.Persons.Orphan> > GetOrphans(int Cid)
        {
            _logger.Information($"trying to get all orphans of the caregiver with id ({Cid})");
            IList <OrphanageDataModel.Persons.Orphan> returnedOrphans = new List <OrphanageDataModel.Persons.Orphan>();

            using (var dbContext = new OrphanageDbCNoBinary())
            {
                var orphans = await(from orp in dbContext.Orphans.AsNoTracking()
                                    where orp.CaregiverId == Cid
                                    select orp)
                              .Include(o => o.Education)
                              .Include(o => o.Name)
                              .Include(o => o.Caregiver.Name)
                              .Include(o => o.Caregiver.Address)
                              .Include(o => o.Family.Father.Name)
                              .Include(o => o.Family.Mother.Name)
                              .Include(o => o.Family.PrimaryAddress)
                              .Include(o => o.Family.AlternativeAddress)
                              .Include(o => o.Guarantor.Name)
                              .Include(o => o.Bail)
                              .Include(o => o.HealthStatus)
                              .ToListAsync();

                if (orphans == null || orphans.Count == 0)
                {
                    _logger.Information($"caregiver with id({Cid}) has no orphans, null will be returned");
                    return(null);
                }
                foreach (var orphan in orphans)
                {
                    var orpToFill = orphan;
                    _selfLoopBlocking.BlockOrphanSelfLoop(ref orpToFill);
                    _uriGenerator.SetOrphanUris(ref orpToFill);
                    _logger.Information($"adding orphan with id({orphan.Id}) to the returned List");
                    returnedOrphans.Add(orpToFill);
                }
            }
            _logger.Information($"({returnedOrphans.Count}) records of orphans will be returned");
            return(returnedOrphans);
        }