Beispiel #1
0
 public StudentModel(string name, string surname, ClassModel clazz, bool gender)
 {
     this.Name = name;
     this.Surname = surname;
     this.Class = clazz;
     this.Gender = gender;
 }
Beispiel #2
0
 public void AddNewClass(ClassModel clazz)
 {
     using (var connection = new System.Data.SQLite.SQLiteConnection(this.connString))
     {
         connection.Open();
         using (var cmd = connection.CreateCommand())
         {
             cmd.CommandText = "INSERT INTO Classes (ClassId, ClassName) VALUES(@Id, @Name)";
             cmd.Parameters.AddWithValue("@Id", clazz.Id);
             cmd.Parameters.AddWithValue("@Name", clazz.Name);
             cmd.ExecuteNonQuery();
         }
     }
 }
Beispiel #3
0
 public StudentModel(int studentId, string name, string surname, ClassModel clazz, bool gender)
     : this(name, surname, clazz, gender)
 {
     this.StudentId = studentId;
 }
Beispiel #4
0
 IList<SubjectModel> GetSubjects(ClassModel selectedClass)
 {
     var timetable = this.GetAllTimeTable();
      return timetable.Where(x => x.Class.Id == selectedClass.Id)
        .Select(x => x.Subject)
        .ToList();
 }
Beispiel #5
0
        TimeTableModel GetTimeTable(ClassModel clazz, SubjectModel subject)
        {
            TimeTableModel timeTable = null;
             using (var connection = new System.Data.SQLite.SQLiteConnection(this.connString))
             {
                 connection.Open();
                 using (var cmd = connection.CreateCommand())
                 {
                     cmd.CommandText = @"SELECT * FROM TimeTables WHERE (ClassId = @classId AND SubjectId = @subjectId)";
                     cmd.Parameters.AddWithValue("@classId", clazz.Id);
                     cmd.Parameters.AddWithValue("@subjectId", subject.Id);
                     using (var reader = cmd.ExecuteReader())
                     {
                         while (reader.Read())
                         {
                             int id = Convert.ToInt32(reader["Id"]);
                             string day = reader["Day"].ToString();
                             var classId = reader["ClassId"] == DBNull.Value ? null : (object)reader["ClassId"].ToString();
                             var subjectId = reader["SubjectId"] == DBNull.Value ? null : (object)reader["SubjectId"].ToString();
                             ClassModel clazzz = this.GetClassById(classId.ToString());
                             SubjectModel sub = this.GetSubjectById(subjectId.ToString());
                             timeTable = new TimeTableModel(id, day, clazzz, sub);
                         }
                     }

                 }
             }
             return timeTable;
        }
Beispiel #6
0
        public List<ClassModel> GetAllClasses()
        {
            List<ClassModel> result = new List<ClassModel>();
            using (var connection = new System.Data.SQLite.SQLiteConnection(this.connString))
            {
                connection.Open();
                using (var cmd = connection.CreateCommand())
                {
                    cmd.CommandText = "SELECT ClassId FROM Classes";
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var id = reader["ClassId"].ToString();
                            var clazz = new ClassModel(id);
                            result.Add(clazz);

                        }
                    }
                }
            }
            return result;
        }
Beispiel #7
0
        public ClassModel GetClassById(string id)
        {
            ClassModel clazz = null;
            using (var connection = new System.Data.SQLite.SQLiteConnection(this.connString))
            {
                connection.Open();
                using (var cmd = connection.CreateCommand())
                {
                    cmd.CommandText = "SELECT * FROM Classes WHERE ClassId = @Id";
                    cmd.Parameters.AddWithValue("@Id", id);
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var idd = reader["ClassId"].ToString();
                            clazz = new ClassModel(idd);
                        }

                    }

                }

            }
            return clazz;
        }
Beispiel #8
0
 public TimeTableModel(string day, ClassModel clazz, SubjectModel subject)
 {
     this.Day = day;
     this.Class = clazz;
     this.Subject = subject;
 }
Beispiel #9
0
 public TimeTableModel(int id, string day, ClassModel clazz, SubjectModel subject)
     : this(day, clazz, subject)
 {
     this.Id = id;
 }
        public void SelectClass(ClassModel selectedItem)
        {
            foreach (var item in this.Classes.Where(x => x.IsSelected))
            {
                item.IsSelected = false;
            }

            selectedItem.IsSelected = true;
            this.NotifyPropertyChanged("SelectedClass");
        }
Beispiel #11
0
 public TimeTableModel GetTimeTable(ClassModel clazz, SubjectModel subject)
 {
     return this.timeTables.Where(x => x.Class.Id == clazz.Id && x.Subject.Id == subject.Id).FirstOrDefault();
 }
Beispiel #12
0
 public IList<SubjectModel> GetSubjectsForClass(ClassModel selectedClass)
 {
     return this.timeTables.Where(x => x.Class.Id == selectedClass.Id)
         .Select(x => x.Subject)
         .ToList();
 }
Beispiel #13
0
 public TimeTableModel GetTimeTable(ClassModel clazz, SubjectModel subject)
 {
     TimeTableEntity timetable = this.timeTableRepository.GetByClassAndSubject(clazz.Id, subject.Id);
     return new TimeTableModel(timetable.Id, timetable.Day, new ClassModel(timetable.Class.Id),
         new SubjectModel(timetable.Subject.Id, timetable.Subject.Name));
 }
Beispiel #14
0
 public IList<SubjectModel> GetSubjectsForClass(ClassModel selectedClass)
 {
     var timeTables = this.timeTableRepository.GetAllByClass(selectedClass.Id);
     IList<SubjectEntity> subjects = timeTables.Select(x => x.Subject).ToList();
     IList<SubjectModel> result = subjects.Select(x => new SubjectModel(x.Id, x.Name)).ToList();
     return result;
 }