Exemple #1
0
        public async Task <IEnumerable <OrphanageDataModel.Persons.Father> > GetFathers(int Uid, int pageSize, int pageNum)
        {
            IList <OrphanageDataModel.Persons.Father> fathersList = new List <OrphanageDataModel.Persons.Father>();

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

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

                foreach (var father in fathers)
                {
                    OrphanageDataModel.Persons.Father fatherToFill = father;
                    FatherDbService.setFatherEntities(ref fatherToFill, _orphanageDBC);
                    _selfLoopBlocking.BlockFatherSelfLoop(ref fatherToFill);
                    _uriGenerator.SetFatherUris(ref fatherToFill);
                    fathersList.Add(fatherToFill);
                }
            }
            return(fathersList);
        }
Exemple #2
0
        public async Task <IEnumerable <OrphanageDataModel.Persons.Father> > GetFathers(int Uid)
        {
            IList <OrphanageDataModel.Persons.Father> fathersList = new List <OrphanageDataModel.Persons.Father>();

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

                foreach (var father in fathers)
                {
                    OrphanageDataModel.Persons.Father fatherToFill = father;
                    FatherDbService.setFatherEntities(ref fatherToFill, _orphanageDBC);
                    _selfLoopBlocking.BlockFatherSelfLoop(ref fatherToFill);
                    _uriGenerator.SetFatherUris(ref fatherToFill);
                    fathersList.Add(fatherToFill);
                }
            }
            return(fathersList);
        }