예제 #1
0
        public async Task <OrphanageDataModel.Persons.Mother> GetMother(int Mid)
        {
            using (var dbContext = new OrphanageDbCNoBinary())
            {
                var mother = await dbContext.Mothers.AsNoTracking()
                             .Include(m => m.Families)
                             .Include(m => m.Name)
                             .Include(m => m.Address)
                             .FirstOrDefaultAsync(m => m.Id == Mid);

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

                _selfLoopBlocking.BlockMotherSelfLoop(ref mother);
                setMotherEntities(ref mother, dbContext);
                _uriGenerator.SetMotherUris(ref mother);
                return(mother);
            }
        }
예제 #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);
        }