public List<Assignment> GetAllAssignments()
        {
            AssignmentDb asDB = new AssignmentDb();
            List<Assignment> asgs = asDB.GetAllAssignments();

            return asgs;
        }
 public ListForObjects GetAllAssignmentsByTeacherId(int teacherId)
 {
     AssignmentDb asDB = new AssignmentDb();
     PersonCtrl userCtrl = new PersonCtrl();
     ListForObjects list = new ListForObjects();
     ListForObjects l = asDB.GetAllAssignmentsByTeacherId(teacherId);
     foreach (Object o in l.Asl)
     {
         Assignment a = (Assignment)o;
         a.teacher = (Teacher)userCtrl.GetPerson(a.teacher.Id);
         list.Asl.Add(a);
     }
     return list;
 }
        public int CreateAssignment(int teacherId, string subject, string title, string exercise, DateTime date, DateTime deadline)
        {
            Assignment asg = new Assignment();
            asg.Teacher = new Person(teacherId);
            asg.Subject = subject;
            asg.Title = title;
            asg.Exercise = exercise;
            asg.Date = date;
            asg.Deadline = deadline;

            asgDb = new AssignmentDb();

            return asgDb.CreateAssignment(asg);
        }
        public int CreateAssignment(int teacherId, string subject, string title, string exercise, DateTime date, DateTime deadline)
        {
            PersonCtrl usCtrl = new PersonCtrl();

            Assignment ass = new Assignment();
            ass.teacher = (Teacher)usCtrl.GetPerson(teacherId);
            ass.subject = subject;
            ass.title = title;
            ass.exercise = exercise;
            ass.date = date;
            ass.deadline = deadline;

            AssignmentDb assDb = new AssignmentDb();

            return assDb.CreateAssignment(ass);
        }
        public List<Assignment> GetAllAssignmentsByTeacher(int teacherId)
        {
            asgDb = new AssignmentDb();

            return asgDb.GetAllAssignmentsByTeacher(teacherId);
        }
        public List<Assignment> GetAllAssignments()
        {
            asgDb = new AssignmentDb();

            return asgDb.GetAllAssignments();
        }
        private List<Homework> MiscWhere(string where, Boolean retrieveAssociation)
        {
            List<Homework> hws = new List<Homework>();

            try
            {
                cmd = new SqlCommand();
                cmd.CommandText = BuildQuery(where);

                dbCon = new DbConnection();
                cmd.Connection = dbCon.GetConnection();
                cmd.Connection.Open();

                cmd.CommandType = CommandType.Text;
                SqlDataReader dr = cmd.ExecuteReader();

                Homework hw = null;
                while (dr.Read())
                {
                    hw = BuildHomework(dr);
                    if (retrieveAssociation)
                    {
                        PersonDb persDb = new PersonDb();
                        int childId = hw.Child.Id;
                        Person child = persDb.SingleWhere("pid = '" + childId + "'", false);
                        hw.Child = child;

                        AssignmentDb asgDb = new AssignmentDb();
                        int assignmentId = hw.Assignment.Id;
                        Assignment asg = asgDb.SingleWhere("aid = '" + assignmentId + "'", false);
                        hw.Assignment = asg;
                    }
                    hws.Add(hw);
                }
                dr.Close();
            }
            catch
            {
                throw;
            }
            return hws;
        }