public void AddNewPupil(List <object[]> AllStaff)
 {
     using (this.StaffCtx = new StaffContext(nameorConnectionString))
     {
         var PupilsToAdd = new List <Pupil>();
         foreach (object[] row in AllStaff)
         {
             int Int32Row0 = Convert.ToInt32(row[0]);
             var result    = StaffCtx.Pupils.SingleOrDefault(p => p.PupilIdOld == Int32Row0);
             if (result == null)
             {
                 Pupil Student = new Pupil();
                 Student.PupilIdOld     = Convert.ToInt32(row[0]);
                 Student.FirstName      = row[2].ToString();
                 Student.LastName       = row[1].ToString();
                 Student.MiddleName     = row[3].ToString();
                 Student.FullFIO        = row[22].ToString();
                 Student.Clas           = row[21].ToString();
                 Student.EljurAccountId = Convert.ToInt32(row[20]);
                 PupilsToAdd.Add(Student);
             }
         }
         foreach (Pupil p in PupilsToAdd)
         {
             StaffCtx.Pupils.Add(p);
             StaffCtx.SaveChanges();
             message.Display("New Student success saved", "Warn");
         }
     }
 }
        public void UpdateStaff(List <object[]> AllStaff)
        {
            using (this.StaffCtx = new StaffContext(nameorConnectionString))
            {
                foreach (object[] row in AllStaff)
                {
                    int Int32Row0 = Convert.ToInt32(row[0]);
                    var result    = StaffCtx.Pupils.SingleOrDefault(p => p.PupilIdOld == Int32Row0);
                    if (result != null)
                    {
                        result.FirstName      = row[2].ToString();
                        result.LastName       = row[1].ToString();
                        result.MiddleName     = row[3].ToString();
                        result.FullFIO        = row[22].ToString();
                        result.FirstName      = row[2].ToString();
                        result.Clas           = row[21].ToString();
                        result.EljurAccountId = Convert.ToInt32(row[20]);
                    }
                }
                StaffCtx.SaveChanges();

                var students = StaffCtx.Pupils;
                message.Display("List of objects:", "Info");
                foreach (Pupil p in students)
                {
                    message.Display(String.Format("{0}.{1} - {2} - {3} - {4} - {5}", p.PupilId, p.FirstName, p.LastName, p.MiddleName, p.FullFIO, p.Clas), "Info");
                }
            }
        }
Exemple #3
0
        public void FillStaffDb(List <object[]> AllStaff)
        {
            using (this.StaffCtx = new StaffContext(nameorConnectionString))
            {
                foreach (object[] row in AllStaff)
                {
                    Pupil Student = new Pupil();
                    Student.PupilIdOld     = Convert.ToInt32(row[0]);
                    Student.FirstName      = row[2].ToString();
                    Student.LastName       = row[1].ToString();
                    Student.MiddleName     = row[3].ToString();
                    Student.FullFIO        = row[22].ToString();
                    Student.Clas           = row[21].ToString();
                    Student.EljurAccountId = Convert.ToInt32(row[20]);

                    StaffCtx.Pupils.Add(Student);
                    StaffCtx.SaveChanges();
                    message.Display("Student success saved", "Warn");
                }
                var students = StaffCtx.Pupils;
                message.Display("List of objects:", "Info");
                foreach (Pupil p in students)
                {
                    message.Display(String.Format("{0}.{1} - {2} - {3} - {4} - {5}", p.PupilId, p.FirstName, p.LastName, p.MiddleName, p.FullFIO, p.Clas), "Info");
                }
            }
        }
Exemple #4
0
 public void SetOneFullEventForTesting(Event TestEvent)
 {
     using (this.StaffCtx = new StaffContext(nameorConnectionString))
     {
         StaffCtx.Events.Add(TestEvent);
         StaffCtx.SaveChanges();
         message.Display("TestEvent success saved", "Warn");
     }
 }
Exemple #5
0
 public void SetTestScheduleForTesting(Schedule TestSchedule)
 {
     using (this.StaffCtx = new StaffContext(nameorConnectionString))
     {
         StaffCtx.Schedules.Add(TestSchedule);
         StaffCtx.SaveChanges();
         message.Display("TestSchedule success saved", "Warn");
     }
 }
Exemple #6
0
 public void SetOneTestPupilForTesting(Pupil TestPupil)
 {
     using (this.StaffCtx = new StaffContext(nameorConnectionString))
     {
         StaffCtx.Pupils.Add(TestPupil);
         StaffCtx.SaveChanges();
         message.Display("TestPupil success saved", "Warn");
     }
 }
Exemple #7
0
 public void SetStatusNotifyWasSend(int PupilIdOld)
 {
     using (this.StaffCtx = new StaffContext(nameorConnectionString))
     {
         var result = StaffCtx.Events.SingleOrDefault(e => e.PupilIdOld == PupilIdOld);
         if (result != null)
         {
             result.NotifyWasSend = true;
             StaffCtx.SaveChanges();
             message.Display("Status NotifyWasSend to " + PupilIdOld + " PupilIdOld was set", "Trace");
         }
     }
 }
Exemple #8
0
 public void SetStatusCameTooLate(int PupilIdOld)
 {
     using (this.StaffCtx = new StaffContext(nameorConnectionString))
     {
         var result = StaffCtx.Events.SingleOrDefault(e => e.PupilIdOld == PupilIdOld);
         if (result != null)
         {
             result.EventName = "Опоздал";
             StaffCtx.SaveChanges();
             message.Display("CameTooLate to " + PupilIdOld + " PupilIdOld was set", "Trace");
         }
     }
 }
Exemple #9
0
 public void SetClasByPupilIdOld(int PupilIdOld, String Clas)
 {
     using (this.StaffCtx = new StaffContext(nameorConnectionString))
     {
         var result = StaffCtx.Pupils.SingleOrDefault(e => e.PupilIdOld == PupilIdOld);
         if (result != null)
         {
             result.Clas = Clas;
             StaffCtx.SaveChanges();
             message.Display("Clas to " + PupilIdOld + " PupilIdOld was updated", "Info");
         }
     }
 }
Exemple #10
0
 public void SetNotifyEnableByPupilIdOld(int PupilIdOld, bool NotifyEnable)
 {
     using (this.StaffCtx = new StaffContext(nameorConnectionString))
     {
         var result = StaffCtx.Pupils.SingleOrDefault(p => p.PupilIdOld == PupilIdOld);
         if (result != null)
         {
             result.NotifyEnable = NotifyEnable;
             StaffCtx.SaveChanges();
             message.Display("Status NotifyWasSend to " + PupilIdOld + " PupilIdOld was set", "Trace");
         }
     }
 }
Exemple #11
0
 public void SetDelAllSchedulesForTesting()
 {
     using (this.StaffCtx = new StaffContext(nameorConnectionString))
     {
         var rows = from s in StaffCtx.Schedules
                    select s;
         foreach (var row in rows)
         {
             StaffCtx.Schedules.Remove(row);
         }
         StaffCtx.SaveChanges();
         message.Display("TestSchedule success removed", "Warn");
     }
 }
Exemple #12
0
 public void SetUpdatedEvent(Event UpdatedEvent)
 {
     using (this.StaffCtx = new StaffContext(nameorConnectionString))
     {
         var result = StaffCtx.Events.SingleOrDefault(e => e.PupilIdOld == UpdatedEvent.PupilIdOld);
         if (result != null)
         {
             result.EventName     = UpdatedEvent.EventName;
             result.EventTime     = UpdatedEvent.EventTime;
             result.NotifyWasSend = UpdatedEvent.NotifyWasSend;
             StaffCtx.SaveChanges();
             message.Display("UpdatedEvent success updated", "Warn");
         }
     }
 }
 public void FillSchedulesDb(List <object[]> AllClasses)
 {
     using (this.StaffCtx = new StaffContext(nameorConnectionString))
     {
         foreach (object[] ScheduleRow in AllClasses)
         {
             Schedule ScheduleItem = new Schedule();
             ScheduleItem.Clas             = ScheduleRow[0].ToString();
             ScheduleItem.StartTimeLessons = TimeSpan.Parse(ScheduleRow[1].ToString());
             ScheduleItem.EndTimeLessons   = TimeSpan.Parse(ScheduleRow[2].ToString());
             StaffCtx.Schedules.Add(ScheduleItem);
             StaffCtx.SaveChanges();
             message.Display("ScheduleItem success saved", "Warn");
         }
     }
 }
Exemple #14
0
        public void CleanOldStaff(List <object[]> AllStaff)
        {
            using (this.StaffCtx = new StaffContext(nameorConnectionString))
            {
                IQueryable <Pupil> Pupils = from p in StaffCtx.Pupils select p;
                var PupilsToDel           = new List <Pupil>();
                foreach (Pupil p in Pupils)
                {
                    var result = AllStaff.SingleOrDefault(s => Convert.ToInt32(s[0]) == p.PupilIdOld);
                    if (result == null)
                    {
                        PupilsToDel.Add(p);
                    }
                }

                foreach (Pupil p in PupilsToDel)
                {
                    StaffCtx.Pupils.Remove(p);
                    StaffCtx.SaveChanges();
                    message.Display("Pupil with " + p.PupilIdOld + " PupilIdOld was cleared in Pupils Table", "Warn");
                }
            }
        }