public async Task <OrphanageDataModel.Persons.Father> GetFather(int Fid) { _logger.Information($"trying to get father with Id ({Fid})"); using (var dbContext = new OrphanageDbCNoBinary()) { var father = await dbContext.Fathers.AsNoTracking() .Include(f => f.Families) .Include(f => f.Name) .FirstOrDefaultAsync(f => f.Id == Fid); if (father == null) { _logger.Warning($"Father with id{Fid} cannot be found null is returned"); return(null); } _selfLoopBlocking.BlockFatherSelfLoop(ref father); setFatherEntities(ref father, dbContext); _uriGenerator.SetFatherUris(ref father); father.OrphansCount = await GetOrphansCount(Fid, dbContext); father.WifeName = await(GetWifeName(father)); _logger.Information($"returned Father with id {Fid}"); return(father); } }
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); }