public List <CoachDTO> findAll() { List <CoachDTO> coachsDTO = new List <CoachDTO>(); var coachs = context.coach .Include("user") .ToList(); coachs.ForEach(x => coachsDTO.Add(CoachDTO.from(x))); return(coachsDTO); }
public List <CoachDTO> findByName(string name) { List <CoachDTO> coachsDTO = new List <CoachDTO>(); var coachs = context.coach .Include("user") .Where(x => x.user.firstName == name && x.available) .ToList(); coachs.ForEach(x => coachsDTO.Add(CoachDTO.from(x))); return(coachsDTO); }
public List <CoachDTO> findByAthleteId(int athleteId) { List <CoachDTO> coachsDTO = new List <CoachDTO>(); var coachsByAth = context.coachByAthelete .Include("coach") .Where(c => c.available && c.atheleteId == athleteId) .ToList(); coachsByAth.ForEach(x => coachsDTO.Add(CoachDTO.from(x.coach))); return(coachsDTO); }
public CoachDTO findById(int id) { var x = context.coach .Include("user") .FirstOrDefault(c => c.id == id && c.available); if (x == null) { return(null); } return(CoachDTO.from(x)); }