예제 #1
0
 //repozytorium klas
 public void AddNewSubject(SubjectModel subject)
 {
     using (var connection = new System.Data.SQLite.SQLiteConnection(this.connString))
     {
         connection.Open();
         using (var cmd = connection.CreateCommand())
         {
             cmd.CommandText = "INSERT INTO Subjects (SubjectId, SubjectName) VALUES(@Id, @Name)";
             cmd.Parameters.AddWithValue("@Id", subject.Id);
             cmd.Parameters.AddWithValue("@Name", subject.Name);
             cmd.ExecuteNonQuery();
         }
     }
 }
예제 #2
0
 public PresenceModel(StudentModel student, SubjectModel subjectModel, DateTime dateTime, PresenceEntity entity)
 {
     this.Student = student;
     this.Subject = subjectModel;
     if (entity != null)
     {
         this.Id = entity.Id;
         this.Present = entity.Present;
         this.Date = entity.Date;
     }
     else
     {
         this.Date = dateTime;
     }
 }
예제 #3
0
 public PresenceModel(StudentModel student, SubjectModel subjectModel, DateTime dateTime, PresenceEntity entity)
 {
     this.Student = student;
     this.Subject = subjectModel;
     if (entity != null)
     {
         this.Id      = entity.Id;
         this.Present = entity.Present;
         this.Date    = entity.Date;
     }
     else
     {
         this.Date = dateTime;
     }
 }
예제 #4
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;
        }
예제 #5
0
        public SubjectModel GetSubjectById(string id)
        {
            SubjectModel subject = null;
            using (var connection = new System.Data.SQLite.SQLiteConnection(this.connString))
            {
                connection.Open();
                using (var cmd = connection.CreateCommand())
                {
                    cmd.CommandText = "SELECT * FROM Subjects WHERE SubjectId = @Id";
                    cmd.Parameters.AddWithValue("@Id", id);
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var idd = reader["SubjectId"].ToString();
                            var name = reader["SubjectName"].ToString();
                            subject = new SubjectModel(idd, name);
                        }

                    }

                }

            }
            return subject;
        }
예제 #6
0
        public List<SubjectModel> GetAllSubjects()
        {
            List<SubjectModel> result = new List<SubjectModel>();
            using (var connection = new System.Data.SQLite.SQLiteConnection(this.connString))
            {
                connection.Open();
                using (var cmd = connection.CreateCommand())
                {
                    cmd.CommandText = "SELECT SubjectId, SubjectName FROM Subjects";
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var id = reader["SubjectId"].ToString();
                            var name = reader["SubjectName"].ToString();
                            var subject = new SubjectModel(id, name);
                            result.Add(subject);

                        }
                    }
                }
            }
            return result;
        }
예제 #7
0
 public TimeTableModel(int id, string day, ClassModel clazz, SubjectModel subject)
     : this(day, clazz, subject)
 {
     this.Id = id;
 }
예제 #8
0
 public TimeTableModel(string day, ClassModel clazz, SubjectModel subject)
 {
     this.Day     = day;
     this.Class   = clazz;
     this.Subject = subject;
 }
예제 #9
0
 public TimeTableModel(int id, string day, ClassModel clazz, SubjectModel subject)
     : this(day, clazz, subject)
 {
     this.Id = id;
 }
예제 #10
0
 public TimeTableModel(string day, ClassModel clazz, SubjectModel subject)
 {
     this.Day = day;
     this.Class = clazz;
     this.Subject = subject;
 }
예제 #11
0
        public void SelectSubject(SubjectModel selectedItem)
        {
            foreach (var item in this.Subjects.Where(x => x.IsSelected))
            {
                item.IsSelected = false;
            }

            selectedItem.IsSelected = true;
            this.NotifyPropertyChanged("SelectedSubject");
        }
예제 #12
0
 public TimeTableModel GetTimeTable(ClassModel clazz, SubjectModel subject)
 {
     return this.timeTables.Where(x => x.Class.Id == clazz.Id && x.Subject.Id == subject.Id).FirstOrDefault();
 }
예제 #13
0
 //public async Task SavePresences(IList<PresenceModel> list)
 //{
 //    await Task.Run(() =>
 //    {
 //        foreach (PresenceModel c in list)
 //        {
 //            if (this.presences.Where(x => x.Date.Date == c.Date.Date && x.Subject.Id == c.Subject.Id && x.Student.FullName == c.Student.FullName).FirstOrDefault() == null)
 //            {
 //                this.presences.Add(c);
 //            }
 //        }
 //        return;
 //    });
 //}
 public IList<PresenceModel> GetPresencesByStudentsSubjectDate(IList<StudentModel> students, SubjectModel subjectModel, DateTime dateTime)
 {
     IList<PresenceModel> list = new List<PresenceModel>();
     foreach (StudentModel s in students)
     {
         var p = this.presences.Where(x => x.Student.FullName == s.FullName && x.Subject.Id == subjectModel.Id && x.Date.Date == dateTime.Date).FirstOrDefault();
         if (p != null)
         {
             list.Add(p);
         }
         else
         {
             list.Add(new PresenceModel(s, subjectModel, dateTime, null));
         }
     }
     return list;
 }
예제 #14
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));
 }
예제 #15
0
        public IList<PresenceModel> GetPresencesByStudentsSubjectDate(IList<StudentModel> students, SubjectModel subjectModel, DateTime dateTime)
        {
            IList<PresenceModel> list = new List<PresenceModel>();
            foreach (StudentModel student in students)
            {
                PresenceEntity presence = this.presenceRepository.GetByStudentAndSubjectAndDate(student.StudentId, subjectModel.Id, dateTime);
                list.Add(new PresenceModel(student, subjectModel, dateTime, presence));
            }

            return list;
        }