Beispiel #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     groupController.AddGroup(new Group {
         GroupName = textBox1.Text, Courses = int.Parse(textBox2.Text)
     });
     this.Close();
 }
 private void MenuItem_OnClicked(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(Subject.Text) || string.IsNullOrEmpty(place.Name))
     {
         group.UserID            = uc.currentUser.ID;
         group.Name              = Subject.Text;
         group.MeetupLocation    = place.Name;
         group.MeetupLocationId  = PlaceId;
         group.MeetupLocationLat = place.Latitude;
         group.MeetupLocationLon = place.Longitude;
         group.MeetupDateTime    = StartDate.Date.Add(StartTime.Time);
         group.MeetupDateTimeEnd = EndDate.Date.Add(EndTime.Time);
         //add event on database for events
         //add the event on the selected attendees
         Trace.WriteLine("To add: " + group.UserID + "/" + group.Name + "/" + group.MeetupLocation + "/" + group.MeetupLocationId + "/" + group.MeetupLocationLat + "/" + group.MeetupLocationLon + "/" + group.MeetupDateTime + "/" + group.MeetupDateTimeEnd);
         gc.AddGroup(group, this);
         ev.EventOverlay.IsVisible = false;
         GetGroupsFromAddEvent();
         ev.MeetingsListViewLead.ItemsSource = ev.GroupsManaged;
     }
     else
     {
         DisplayAlert("Error", "Fields cannot be blank.", "Try again");
     }
 }
Beispiel #3
0
 public void TestAddGroup()
 {
     TestGroupController = new GroupController(TestRepository);
     for (var i = 0; i < 100; i++)
     {
         TestGroupController.AddGroup(new ISGroup(i, 215 + i));
     }
     try
     {
         TestGroupController.AddGroup(new ISGroup(99, 216));
         Assert.Fail();
     }
     catch (Exception e)
     {
         Assert.AreEqual("Group with 99 id, is already exist!", e.Message);
     }
     Assert.AreEqual(new Student(5).Id, TestGroupController.GetGroup(5).Id);
 }
Beispiel #4
0
        public void TestInit()
        {
            TestGroupController = new GroupController(TestRepository);
            Assert.IsInstanceOfType(TestGroupController, typeof(GroupController));

            Repository <ISGroup> tRepo = new Repository <ISGroup>();
            GroupController      tCtrl = new GroupController(tRepo);

            tCtrl.AddGroup(new ISGroup(14, 117));
            Assert.AreEqual(14, tRepo[0].Id);
        }
Beispiel #5
0
        public void TestGetGroup()
        {
            TestGroupController = new GroupController(TestRepository);

            for (var i = 0; i < 50; i++)
            {
                TestGroupController.AddGroup(new ISGroup(i, 213 + i));
            }

            Assert.AreEqual(10, TestGroupController.GetGroup(10).Id);
            Assert.AreEqual(15, TestGroupController.GetGroup(15).Id);
            Assert.AreEqual(23, TestGroupController.GetGroup(23).Id);
        }
Beispiel #6
0
        public void TestDeleteGroup()
        {
            TestGroupController = new GroupController(TestRepository);
            for (var i = 0; i < 50; i++)
            {
                TestGroupController.AddGroup(new ISGroup(i, 214 + i));
            }

            for (var i = 0; i < 50; i += 5)
            {
                TestGroupController.RemoveGroup(TestGroupController.GetGroup(i));
            }

            Assert.AreEqual(40, TestGroupController.GetAll().Count);
        }
Beispiel #7
0
        public void TestGetAll()
        {
            TestGroupController = new GroupController(TestRepository);

            for (var i = 0; i < 50; i++)
            {
                TestGroupController.AddGroup(new ISGroup(i, 217 + i));
            }

            var listOfStudents = TestGroupController.GetAll();
            int tId            = 0;

            foreach (var item in listOfStudents)
            {
                Assert.AreEqual(tId, item.Id);
                tId++;
            }
        }
Beispiel #8
0
        public void TestChangeGroup()
        {
            TestGroupController = new GroupController(TestRepository);
            for (var i = 0; i < 50; i++)
            {
                TestGroupController.AddGroup(new ISGroup(i, 214 + i));
            }

            TestGroupController.ChangeGroup(
                TestGroupController.GetGroup(43),
                new ISGroup(90, 216));

            TestGroupController.ChangeGroup(
                TestGroupController.GetGroup(42),
                new ISGroup(80, 215));

            Assert.AreEqual(90, TestGroupController.GetGroup(90).Id);
            Assert.AreEqual(80, TestGroupController.GetGroup(80).Id);
        }
Beispiel #9
0
        /// <summary>
        /// Constructor with params where files loads
        /// </summary>
        /// <param inputString="Path">path to folder where will storage files</param>
        public View(String path)
        {
            Path = path;

            Thread StudentThread = new Thread(() =>
            {
                StudentRepository = new Repository <Student>(Path + "Students.cdat");
                StudentRepository.Load();
            });

            Thread GroupThread = new Thread(() =>
            {
                GroupRepository = new Repository <ISGroup>(Path + "Groups.cdat");
                GroupRepository.Load();
            });

            Thread SubjectThread = new Thread(() =>
            {
                SubjectRepository = new Repository <Subject>(Path + "Subject.cdat");
                SubjectRepository.Load();
            });

            Thread TeacherThread = new Thread(() =>
            {
                TeacherRepository = new Repository <Teacher>(Path + "Teachers.cdat");
                TeacherRepository.Load();
            });

            StudentThread.Start();
            GroupThread.Start();
            SubjectThread.Start();
            TeacherThread.Start();

            while (StudentThread.IsAlive || GroupThread.IsAlive ||
                   SubjectThread.IsAlive || TeacherThread.IsAlive)
            {
                Console.Clear();
                Console.Write("Wait");
                for (int i = 0; i < 5; i++)
                {
                    Thread.Sleep(500);
                    Console.Write(".");
                }
            }
            Console.Clear();
            CommandDictionary = new Dictionary <string, Command>();

            StudentControll = new StudentController(StudentRepository);
            TeacherControll = new TeacherController(TeacherRepository);
            GroupControll   = new GroupController(GroupRepository);
            SearchControll  = new SearchController(StudentRepository, GroupRepository, SubjectRepository);

            // COMMANDS
            CommandDictionary.Add("add student", new Command("add student", "Add new student;"));
            CommandDictionary.Add("add group", new Command("add group", "Add new group;"));
            CommandDictionary.Add("show students", new Command("show students", "Show list of students"));
            CommandDictionary.Add("show groups", new Command("show groups", "Show list of groups"));
            CommandDictionary.Add("student info", new Command("student info", "Show information about student"));
            CommandDictionary.Add("group info", new Command("group info", "Show information about group"));
            CommandDictionary.Add("add subject", new Command("add subject", "Add new subject;"));
            CommandDictionary.Add("add teacher", new Command("add teacher", "Add new teacher;"));
            CommandDictionary.Add("add student to group", new Command("add student to group", "Add student to group"));
            CommandDictionary.Add("add teacher to group", new Command("add teacher to group", "Add teacher to group"));
            CommandDictionary.Add("set subject teacher", new Command("set subject teacher", "Set teacher for subject"));
            CommandDictionary.Add("find students by group", new Command("find students by group", "View all students of group"));
            CommandDictionary.Add("find students by teacher", new Command("find students by teacher", "View all students of teacher"));
            CommandDictionary.Add("find students by subject", new Command("find students by subject", "View all students of subject"));
            CommandDictionary.Add("clr", new Command("clr", "Delete all inforamation from screen"));
            CommandDictionary.Add("exit", new Command("exit", "Close the application;"));
            CommandDictionary.Add("help", new Command("help", "Information about all commands;"));

            // ACTION OF COMMANDS
            CommandDictionary["add group"].SetAction(() =>
            {
                GroupControll.AddGroup(GetGroup());
            });

            CommandDictionary["add subject"].SetAction(() =>
            {
                SubjectRepository.Add(GetSubject());
            });

            CommandDictionary["add teacher"].SetAction(() =>
            {
                TeacherRepository.Add(GetTeacher());
            });

            CommandDictionary["add student"].SetAction(() =>
            {
                StudentControll.AddStudent(GetStudent());
            });

            CommandDictionary["add teacher to group"].SetAction(() =>
            {
                var groupId   = GetId("group");
                var teacherId = GetId("teacher");
                GroupControll.GetGroup(groupId).AddTeacher(teacherId);
            });

            CommandDictionary["add student to group"].SetAction(() =>
            {
                var groupId   = GetId("group");
                var studentId = GetId("student");
                GroupControll.GetGroup(groupId).AddStudent(studentId);
            });

            CommandDictionary["set subject teacher"].SetAction(() =>
            {
                var subId     = GetId("subject");
                var teacherId = GetId("teacher");
                SubjectRepository[subId].SetTeacher(teacherId);
            });

            CommandDictionary["show students"].SetAction(() =>
            {
                var listOfStudents = StudentControll.GetAll();
                Console.WriteLine("Students:");
                Console.WriteLine("--------------------------------------");
                foreach (Student student in listOfStudents)
                {
                    Console.WriteLine("Id: {0}; Name: {1}; Surname: {2};",
                                      student.Id, student.Name, student.Surname);
                }
                Console.WriteLine("--------------------------------------");
            });

            CommandDictionary["show groups"].SetAction(() =>
            {
                var listOfGroups = GroupControll.GetAll();
                Console.WriteLine("Groups:");
                Console.WriteLine("--------------------------------------");
                foreach (ISGroup group in listOfGroups)
                {
                    Console.WriteLine("Id: {0}; Number: {1};", group.Id, group.Number);
                }
                Console.WriteLine("--------------------------------------");
            });

            CommandDictionary["group info"].SetAction(() =>
            {
                ISGroup group = GroupControll.GetGroup(GetId("group"));
                Console.WriteLine("Group:{0}", group.Id);
                Console.WriteLine("Number:{0}", group.Number);
                Console.WriteLine("--------------------------------------");
                Console.WriteLine("Students:");
                foreach (int id in group.StudentIDs)
                {
                    Student student = StudentControll.GetStudent(id);
                    Console.WriteLine("Id: {0}; Name: {1}; Surname: {2};", id, student.Name, student.Surname);
                }
                Console.WriteLine("--------------------------------------");
                Console.WriteLine("Teachers that teach group:");
                foreach (int id in group.TeacherIDs)
                {
                    Teacher queryTeacher = TeacherRepository
                                           .Where(teacher => teacher.Id == id).Single();
                    Console.WriteLine("Id: {0}; Name: {1}; Surname: {2};", id, queryTeacher.Name, queryTeacher.Surname);
                }
                Console.WriteLine("--------------------------------------");
            });

            CommandDictionary["student info"].SetAction(() =>
            {
                Student student = StudentControll.GetStudent(GetId("student"));
                Console.WriteLine("----------------------------------------");
                Console.WriteLine("Id: {0};", student.Id);
                Console.WriteLine("Name: {0};", student.Name);
                Console.WriteLine("Surname: {0};", student.Surname);
                Console.WriteLine("Course: {0};", student.Course);
                Console.WriteLine("Course: {0};", student.GradeBook);
                Console.WriteLine("Address: {0};", student.Address);
                Console.WriteLine("Mobile number: {0};", student.MobilePhone);
                Console.WriteLine("----------------------------------------");
            });

            CommandDictionary["find students by group"].SetAction(() =>
            {
                var listOfStudents = SearchControll.SearchByGroup(GetId("group"));
                foreach (Student student in listOfStudents)
                {
                    Console.WriteLine("Id: {0}; Name: {1}; Surname: {2};", student.Id, student.Name, student.Surname);
                }
            });

            CommandDictionary["find students by teacher"].SetAction(() =>
            {
                var listOfStudents = SearchControll.SearchByTeacher(GetId("teacher"));
                foreach (Student student in listOfStudents)
                {
                    Console.WriteLine("Id: {0}; Name: {1}; Surname: {2};", student.Id, student.Name, student.Surname);
                }
            });

            CommandDictionary["find students by subject"].SetAction(() =>
            {
                var listOfStudents = SearchControll.SearchByGroup(GetId("subject"));
                foreach (Student student in listOfStudents)
                {
                    Console.WriteLine("Id: {0}; Name: {1}; Surname: {2};", student.Id, student.Name, student.Surname);
                }
            });

            CommandDictionary["help"].SetAction(() =>
            {
                foreach (Command item in CommandDictionary.Values)
                {
                    Console.WriteLine("{0} : {1}", item.Text, item.Description);
                }
            });

            CommandDictionary["clr"].SetAction(() =>
            {
                Console.Clear();
            });

            CommandDictionary["exit"].SetAction(() =>
            {
                Console.WriteLine("Okey :( Good bye!");
                Exit();
                Environment.Exit(0);
            });

            MainMenu();
        }