public static Registry Convert(RegistryData item) { try { if (item == null) { throw new Exception("Parâmetro vazio"); } var grid = GridDAO.Find(item.IdGrid); if (grid == null) { throw new Exception("Grade não encontrado"); } var student = StudentDAO.Find(item.IdStudent); if (student == null) { throw new Exception("Aluno não encontrado"); } return(new Registry { IdRegistry = item.IdRegistry, Grid = grid, Student = student, Alternative = item.Alternative, RegisterDate = item.RegisterDate, RegisterBy = item.RegisterBy, DeleteDate = item.DeleteDate, DeleteBy = item.DeleteBy }); } catch (Exception e) { string notes = LogHelper.Notes(item, e.Message); Log.Add(Log.TYPE_ERROR, "SistemaMatricula.DAO.RegistryDAO.Convert", notes); } return(null); }
public static List <Registry> GridList(Guid idStudent, Guid idCourse) { try { if (idStudent == null || Equals(idStudent, Guid.Empty)) { throw new Exception("Parâmetro 'idStudent' vazio"); } if (idCourse == null || Equals(idCourse, Guid.Empty)) { throw new Exception("Parâmetro 'idCourse' vazio"); } Semester semester = SemesterDAO.Last(); if (semester == null) { throw new Exception("Semestre não encontrado"); } List <GridData> grid = null; using (Entities db = new Entities()) { grid = db.GridData .Where(g => g.DeleteDate == null && db.SemesterData .Where(s => s.InitialDate == semester.InitialDate) .Select(s => s.IdSemester) .Contains(g.IdSemester) && !db.RegistryData .Where(r => r.DeleteDate == null && r.IdStudent == idStudent) .Select(r => r.IdGrid) .Contains(g.IdGrid) && db.ClassData .Where(c => c.IdCourse == idCourse) .Select(c => c.IdClass) .Contains(g.IdClass) && g.Status.Trim() == Grid.RELEASED) .ToList(); } if (grid.Count < 1) { return(new List <Registry>()); } Student student = StudentDAO.Find(idStudent); List <Registry> list = grid .Select(x => new Registry() { Grid = GridDAO.Convert(x), Student = student }) .OrderBy(x => x.Grid.Semester.Name) .ThenBy(x => x.Grid.Weekday) .ThenBy(x => x.Grid.Time) .ToList(); return(list); } catch (Exception e) { object[] parameters = { idStudent, idCourse }; string notes = LogHelper.Notes(parameters, e.Message); Log.Add(Log.TYPE_ERROR, "SistemaMatricula.DAO.RegistryDAO.GridList", notes); } return(null); }