Ejemplo n.º 1
0
        public List <ProfesoresPorTematica> getProfesorPorTematica(int id)
        {
            var responseTask = conexion.client.GetAsync("Tematica/" + id + "/profesores");

            responseTask.Wait();
            var result = responseTask.Result;

            if (result.IsSuccessStatusCode)
            {
                var readTask = result.Content.ReadAsStringAsync();
                readTask.Wait();
                JavaScriptSerializer serializer = new JavaScriptSerializer();

                var profesorPorTematica                = serializer.Deserialize <List <PorfesorPorTematica> >(readTask.Result);
                var profesoresPorTematica2             = new ProfesoresPorTematica();
                var profesorPorTematicaSinConcurrencia = profesoresPorTematica2.getProfesoresPorTematicas(profesorPorTematica);
                return(profesorPorTematicaSinConcurrencia);
            }

            return(new List <ProfesoresPorTematica>());
        }
Ejemplo n.º 2
0
        public List <ProfesoresPorTematica> getProfesoresPorTematicas(List <PorfesorPorTematica> lista)
        {
            List <PorfesorPorTematica>   listaTemporal         = lista;
            List <ProfesoresPorTematica> listaSinConcurrencias = new List <ProfesoresPorTematica>();

            while (lista.Count != 0)
            {
                foreach (var elemento in listaTemporal.ToList())
                {
                    List <PorfesorPorTematica> concurrencias = new List <PorfesorPorTematica>();
                    concurrencias = listaTemporal.FindAll(x => x.IdProfesor == elemento.IdProfesor);

                    ProfesoresPorTematica profesorTematica = new ProfesoresPorTematica();
                    profesorTematica.IdProfesor      = elemento.IdProfesor;
                    profesorTematica.NombreProfesor  = elemento.Nombre;
                    profesorTematica.PrimerApellido  = elemento.PrimerApellido;
                    profesorTematica.SegundoApellido = elemento.SegundoApellido;
                    profesorTematica.NombreLugar     = elemento.NombreLugar;
                    profesorTematica.Especialidades  = elemento.Especialidades;
                    profesorTematica.stringFoto      = elemento.stringFoto;
                    profesorTematica.Usuario         = elemento.Usuario;
                    foreach (var value in concurrencias)
                    {
                        Horario horarioProfesor = new Horario();
                        horarioProfesor.Dia        = value.Dia;
                        horarioProfesor.HoraInicio = value.HoraInicio;
                        horarioProfesor.HoraFinal  = value.HoraFinal;
                        profesorTematica.horarios.Add(horarioProfesor);
                    }
                    if (!listaSinConcurrencias.Exists(x => x.IdProfesor == profesorTematica.IdProfesor))
                    {
                        listaSinConcurrencias.Add(profesorTematica);
                    }


                    listaTemporal.RemoveAll(x => x.IdProfesor == elemento.IdProfesor);
                }
            }
            return(listaSinConcurrencias);
        }