示例#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;
 }
        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;
        }