public IEnumerable <StudentDetailDto> Get()
        {
            DbTools dBTools = new DbTools();
            var     data    = dBTools.GetDataTable(@"SELECT * FROM Student s, Class c WHERE s.IdClass = c.Id;");
            List <StudentDetailDto> students = new List <StudentDetailDto>();

            foreach (DataRow item in data.Rows)
            {
                students.Add(ParseToStudent(item));
            }
            return(students);
        }
        public IEnumerable <Classroom> Get()
        {
            List <Classroom> classrooms = new List <Classroom>();
            DbTools          dBTools    = new DbTools();
            var data = dBTools.GetDataTable(@"SELECT * FROM Class").Rows;

            foreach (DataRow item in data)
            {
                classrooms.Add(new Classroom(Convert.ToInt32(item["Id"]), Convert.ToInt32(item["Year"]), item["Section"].ToString(), item["Specialization"].ToString()));
            }
            return(classrooms);
        }
        public IEnumerable <Subject> Get()
        {
            List <Subject> subjects = new List <Subject>();
            DbTools        dBTools  = new DbTools();
            var            data     = dBTools.GetDataTable(@"SELECT * FROM Subject");

            foreach (DataRow item in data.Rows)
            {
                Subject materia = new Subject(Convert.ToInt32(item["Id"]), item["Description"].ToString(), Convert.ToBoolean(item["IsPeculiar"]));
                subjects.Add(materia);
            }
            return(subjects);
        }
        public ActionResult <StudentDetailDto> Get(int id)
        {
            DbTools dBTools = new DbTools();
            var     data    = dBTools.GetDataTable(@"SELECT * FROM Student s, Class c WHERE s.IdClass = c.Id AND s.Id = " + id);

            if (data.Rows.Count > 0)
            {
                return(ParseToStudent(data.Rows[0]));
            }
            else
            {
                return(NotFound());
            }
        }
        public ActionResult <Subject> Get(int id)
        {
            DbTools dBTools = new DbTools();
            var     item    = dBTools.GetDataTable($@"SELECT * FROM Subject WHERE Id = {id};").Rows;

            if (item.Count > 0)
            {
                Subject subject = new Subject(Convert.ToInt32(item[0]["Id"]), item[0]["Description"].ToString(), Convert.ToBoolean(item[0]["IsPeculiar"]));
                return(subject);
            }
            else
            {
                return(NotFound());
            }
        }
        public ActionResult <Classroom> Get(int id)
        {
            DbTools dBTools = new DbTools();
            var     item    = dBTools.GetDataTable($@"SELECT * FROM Class WHERE Id = {id};").Rows;

            if (item.Count > 0)
            {
                Classroom classroom = new Classroom(Convert.ToInt32(item[0]["Id"]), Convert.ToInt32(item[0]["Year"]), item[0]["Section"].ToString(), item[0]["Specialization"].ToString());
                return(classroom);
            }
            else
            {
                return(NotFound());
            }
        }
        public IEnumerable <ViaggioDto> Get()
        {
            DbTools   db   = new DbTools();
            DataTable data = db.GetDataTable("SELECT a.nome as nomeAutista, a.cognome as cognomeAutista, v.costo, v.cittaPartenza, v.cittaArrivo, v.[data], p.nome as nomePasseggero, p.cognome as cognomePasseggero " +
                                             "FROM Viaggio v, Autisti a, Passeggeri p, Prenotazioni pr " +
                                             "WHERE v.idAutista = a.id_Autista " +
                                             "AND pr.id_Viaggio = v.id_Viaggio " +
                                             "AND pr.id_Utente = p.id_Utente " +
                                             "AND v.isPrenotabile = 1 " +
                                             "AND a.id_Autista = 2 " +
                                             "ORDER BY v.[data];");

            List <ViaggioDto> Viaggi = new List <ViaggioDto>();

            foreach (DataRow row in data.Rows)
            {
                Viaggi.Add(DataRowToViaggio(row));
            }

            return(Viaggi);
        }