Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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));
        }