Skip to content

Commit

Permalink
feat: load owner degree name
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosPavajeau committed Sep 21, 2021
1 parent b02b857 commit 3ba6422
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public async Task<Fireteam> Find(string code, bool noTracking)

return await query
.Include(s => s.Owner)
.ThenInclude(o => o.Degree)
.ThenInclude(d => d.Rank)
.Include(s => s.Flight)
.FirstOrDefaultAsync(s => s.Code == code);
}
Expand All @@ -50,6 +52,7 @@ public async Task<IEnumerable<Fireteam>> SearchAll(bool noTracking)

return await query
.Include(s => s.Owner)
.ThenInclude(o => o.Degree)
.Include(s => s.Flight)
.ToListAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public async Task<Flight> Find(string code, bool noTracking)

return await query
.Include(s => s.Owner)
.ThenInclude(o => o.Degree)
.FirstOrDefaultAsync(s => s.Code == code);
}

Expand All @@ -48,6 +49,7 @@ public async Task<IEnumerable<Flight>> SearchAll(bool noTracking)

return await query
.Include(s => s.Owner)
.ThenInclude(o => o.Degree)
.ToListAsync();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ public FireteamsProfile()
flightName =>
flightName.MapFrom(src => src.Flight == null ? string.Empty : src.Flight.Name))
.ForMember(s => s.OwnerName,
ownerName => ownerName.MapFrom(src => src.Owner == null ? string.Empty : src.Owner.FullName));
ownerName => ownerName.MapFrom(src =>
src.Owner == null
? string.Empty
: $"{src.Owner.FullName} - {src.Owner.Degree.Name}"));
CreateMap<CreateFireteamCommand, Fireteam>();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public FlightsProfile()
{
CreateMap<Flight, FlightResponse>()
.ForMember(s => s.OwnerName,
ownerName => ownerName.MapFrom(src => src.Owner == null ? string.Empty : src.Owner.FullName));
ownerName => ownerName.MapFrom(src =>
src.Owner == null ? string.Empty : $"{src.Owner.FullName} - {src.Owner.Degree.Name}"));
CreateMap<CreateFlightCommand, Flight>();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public SquadsProfile()
CreateMap<CreateSquadCommand, Squad>();
CreateMap<Squad, SquadResponse>()
.ForMember(s => s.OwnerName,
ownerName => ownerName.MapFrom(src => src.Owner == null ? string.Empty : src.Owner.FullName));
ownerName => ownerName.MapFrom(src =>
src.Owner == null ? string.Empty : $"{src.Owner.FullName} - {src.Owner.Degree.Name}"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public async Task<Squad> Find(string code, bool noTracking)

return await query
.Include(s => s.Owner)
.ThenInclude(o => o.Degree)
.FirstOrDefaultAsync(s => s.Code == code);
}

Expand All @@ -47,6 +48,7 @@ public async Task<IEnumerable<Squad>> SearchAll()
return await _context.Squads
.AsNoTracking()
.Include(s => s.Owner)
.ThenInclude(o => o.Degree)
.ToListAsync();
}
}
Expand Down

0 comments on commit 3ba6422

Please sign in to comment.