public StudentModel(string name, string surname, ClassModel clazz, bool gender) { this.Name = name; this.Surname = surname; this.Class = clazz; this.Gender = gender; }
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(); } } }
public StudentModel(int studentId, string name, string surname, ClassModel clazz, bool gender) : this(name, surname, clazz, gender) { this.StudentId = studentId; }
IList<SubjectModel> GetSubjects(ClassModel selectedClass) { var timetable = this.GetAllTimeTable(); return timetable.Where(x => x.Class.Id == selectedClass.Id) .Select(x => x.Subject) .ToList(); }
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; }
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; }
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; }
public TimeTableModel(string day, ClassModel clazz, SubjectModel subject) { this.Day = day; this.Class = clazz; this.Subject = subject; }
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"); }
public TimeTableModel GetTimeTable(ClassModel clazz, SubjectModel subject) { return this.timeTables.Where(x => x.Class.Id == clazz.Id && x.Subject.Id == subject.Id).FirstOrDefault(); }
public IList<SubjectModel> GetSubjectsForClass(ClassModel selectedClass) { return this.timeTables.Where(x => x.Class.Id == selectedClass.Id) .Select(x => x.Subject) .ToList(); }
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)); }
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; }