Example #1
0
        public async Task <IEnumerable <OrphanageDataModel.Persons.Mother> > GetMothers(int Uid, int pageSize, int pageNum)
        {
            IList <OrphanageDataModel.Persons.Mother> mothersList = new List <OrphanageDataModel.Persons.Mother>();

            using (var _orphanageDBC = new OrphanageDbCNoBinary())
            {
                int totalSkiped  = pageSize * pageNum;
                int MothersCount = await _orphanageDBC.Mothers.AsNoTracking().CountAsync();

                if (MothersCount < totalSkiped)
                {
                    totalSkiped = MothersCount - pageSize;
                }
                if (totalSkiped < 0)
                {
                    totalSkiped = 0;
                }
                var mothers = await _orphanageDBC.Mothers.AsNoTracking()
                              .OrderBy(o => o.Id).Skip(() => totalSkiped).Take(() => pageSize)
                              .Include(f => f.Families)
                              .Include(f => f.Name)
                              .Where(m => m.UserId == Uid)
                              .ToListAsync();

                foreach (var mother in mothers)
                {
                    OrphanageDataModel.Persons.Mother motherToFill = mother;
                    MotherDbService.setMotherEntities(ref motherToFill, _orphanageDBC);
                    _selfLoopBlocking.BlockMotherSelfLoop(ref motherToFill);
                    _uriGenerator.SetMotherUris(ref motherToFill);
                    mothersList.Add(motherToFill);
                }
            }
            return(mothersList);
        }
Example #2
0
        public async Task <IEnumerable <OrphanageDataModel.Persons.Mother> > GetMothers(int Uid)
        {
            IList <OrphanageDataModel.Persons.Mother> mothersList = new List <OrphanageDataModel.Persons.Mother>();

            using (var _orphanageDBC = new OrphanageDbCNoBinary())
            {
                var mothers = await _orphanageDBC.Mothers.AsNoTracking()
                              .Include(f => f.Families)
                              .Include(f => f.Name)
                              .Where(m => m.UserId == Uid)
                              .ToListAsync();

                foreach (var mother in mothers)
                {
                    OrphanageDataModel.Persons.Mother motherToFill = mother;
                    MotherDbService.setMotherEntities(ref motherToFill, _orphanageDBC);
                    _selfLoopBlocking.BlockMotherSelfLoop(ref motherToFill);
                    _uriGenerator.SetMotherUris(ref motherToFill);
                    mothersList.Add(motherToFill);
                }
            }
            return(mothersList);
        }