Example #1
0
        private void FillSubjectComboByGradeID(long gradeID)
        {
            SubjectsRepository  subjectsRepository = new SubjectsRepository();
            List <SubjectModel> subjectModels      = new List <SubjectModel>();

            DataTable dataTable = new DataTable();

            try
            {
                dataTable = subjectsRepository.GetAllSubjectsByGradeID(gradeID);

                subjectModels = TranslateDataTableToSubjectsModel(dataTable);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Network error...Please try again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                dataTable.Clear();
                dataTable = null;
            }

            this.cmbSubjects.SelectedIndexChanged -= new EventHandler(cmbSubjects_SelectedIndexChanged);

            BindingSource bs = new BindingSource();

            bs.DataSource             = subjectModels;
            cmbSubjects.ValueMember   = "SubjectID";
            cmbSubjects.DisplayMember = "SubjectName";
            cmbSubjects.DataSource    = bs;
            cmbSubjects.SelectedIndex = -1;

            this.cmbSubjects.SelectedIndexChanged += new EventHandler(cmbSubjects_SelectedIndexChanged);
        }
Example #2
0
        private void teacherEditButton_Click(object sender, EventArgs e)
        {
            var selectedRowIndex = GetSelectedRowIndex(teachersDataGridView);

            if (selectedRowIndex == null)
            {
                return;
            }
            var teacher   = TeachersRepository.GetAll()[(int)selectedRowIndex];
            var teacherVM = new TeacherVM
            {
                Teacher    = teacher,
                SubjectIds = TeacherSubjectRepository.GetSubjectsForTeacher(teacher.Id),
            };

            new DetailedTeacherForm
            (
                teacherVM,
                SubjectsRepository.GetAll(),
                updatedTeacherVM =>
            {
                TeachersRepository.Update(updatedTeacherVM.Teacher);
                TeacherSubjectRepository.UpdateSubjectsForTeacher(updatedTeacherVM.Teacher.Id, updatedTeacherVM.SubjectIds);
                UpdateTeachersGrid();
                return(true);
            }
            ).Show();
        }
Example #3
0
 public AppRepository(CsEvaluatorContext context)
 {
     HomeworkDescriptionRepository = new HomeworkDescriptionRepository(context);
     HomeworkRepository            = new HomeworkRepository(context);
     SubjectsRepository            = new SubjectsRepository(context);
     StudentRepository             = new StudentRepository(context);
 }
Example #4
0
        public void AddSubject(Subjects entityToAdd)
        {
            ISubjectsRepository repo = new SubjectsRepository(getEntities());

            Entities.Subjects entityToAdd2 = Mapper.Map <Subjects, Entities.Subjects>(entityToAdd);
            repo.Add(entityToAdd2);
        }
Example #5
0
        public int GetIdOfSubject(Subjects entityToGetId)
        {
            ISubjectsRepository repo = new SubjectsRepository(getEntities());

            Entities.Subjects entityToGetId2 = Mapper.Map <Subjects, Entities.Subjects>(entityToGetId);
            return(repo.GetSubjectId(entityToGetId2));
        }
Example #6
0
        public void RemoveSubject(Subjects entityToRemove)
        {
            ISubjectsRepository repo = new SubjectsRepository(getEntities());

            Entities.Subjects entityToRemove2 = Mapper.Map <Subjects, Entities.Subjects>(entityToRemove);
            repo.Remove(entityToRemove2);
        }
Example #7
0
        private void subjectEditButton_Click(object sender, EventArgs e)
        {
            var selectedRowIndex = GetSelectedRowIndex(subjectDataGridView);

            if (selectedRowIndex == null)
            {
                return;
            }
            var subject   = SubjectsRepository.GetAll()[(int)selectedRowIndex];
            var subjectVM = new SubjectVM
            {
                Subject    = subject,
                TeacherIds = TeacherSubjectRepository.GetTeachersForSubject(subject.Id),
            };

            new DetailedSubjectForm
            (
                subjectVM,
                TeachersRepository.GetAll(),
                updatedSubjectVM =>
            {
                SubjectsRepository.Update(updatedSubjectVM.Subject);
                TeacherSubjectRepository.UpdateTeachersForSubject(updatedSubjectVM.Subject.Id, updatedSubjectVM.TeacherIds);
                UpdateSubjectsGrid();
                return(true);
            }
            ).Show();
        }
Example #8
0
        public ActionResult Show(int?semester, int?id)
        {
            if (semester == null)
            {
                var subjects    = ScheduleRepository.GetAllSchedule(this.CurrentUser.Class_id);
                var s1          = SubjectsRepository.GetSubjectsByClassAndSemester(this.CurrentUser.Class_id, 1);
                var s2          = SubjectsRepository.GetSubjectsByClassAndSemester(this.CurrentUser.Class_id, 2);
                var allSubjects = SubjectsRepository.GetAllSubjects();

                var vm = new GradesViewModel()
                {
                    Semester1   = s1,
                    Semester2   = s2,
                    AllSubjects = allSubjects
                };

                return(View(vm));
            }
            else if (semester == 1)
            {
                return(ShowFirstSemesterGrades(1, id));
            }
            else
            {
                return(ShowSecondSemesterGrades(2, id));
            }
            return(View());
        }
Example #9
0
        public IEnumerable <Subjects> GetAllSubjects()
        {
            ISubjectsRepository             repo           = new SubjectsRepository(getEntities());
            IEnumerable <Entities.Subjects> returnedValue  = repo.GetAll();
            IEnumerable <Subjects>          returnedValue2 = Mapper.Map <IEnumerable <Entities.Subjects>, IEnumerable <Subjects> >(returnedValue);

            return(returnedValue2);
        }
Example #10
0
        public Subjects GetSubjectById(int entityToGetById)
        {
            ISubjectsRepository repo = new SubjectsRepository(getEntities());

            Entities.Subjects returnedValue  = repo.GetById(entityToGetById);
            Subjects          returnedValue2 = Mapper.Map <Entities.Subjects, Subjects>(returnedValue);

            return(returnedValue2);
        }
 public override void InitParams()
 {
     dbSet  = _context.Subjects;
     r      = new SubjectsRepository(_context);
     model1 = new Subject {
         Name = "phys"
     };
     model2 = new Subject {
         Name = "hist"
     };
 }
Example #12
0
        public DataInitializer(IRepository <Subject> subjectsRepository, IRepository <Student> studentsRepository)
        {
            _subjectsRepository = subjectsRepository as SubjectsRepository;
            _studentsRepository = studentsRepository;

            InitializeStudents();
            InitializeMarks();
            InitializeSubjects();

            Data = _students.Concat <Entity>(_subjects).ToList();
        }
Example #13
0
        // GET: Subjects
        public ActionResult Show()
        {
            var subjects = SubjectsRepository.GetAllSubjects();

            SubjectsViewModel vm = new SubjectsViewModel()
            {
                Subjects = subjects
            };

            return(View(vm));
        }
Example #14
0
        private void subjectDeleteButton_Click(object sender, EventArgs e)
        {
            var selectedRowIndex = GetSelectedRowIndex(subjectDataGridView);

            if (selectedRowIndex == null)
            {
                return;
            }
            SubjectsRepository.Delete(SubjectsRepository.GetAll()[(int)selectedRowIndex].Id);
            UpdateSubjectsGrid();
        }
Example #15
0
 /// <summary>
 /// Konstruktor
 /// </summary>
 public FormAdmin()
 {
     InitializeComponent();
     workersRepository         = new WorkersRepository();
     studentsRepository        = new StudentsRepository();
     fieldsOfStudyRepository   = new FieldsOfStudiesRepository();
     residencePlacesRepository = new AddressesRepository();
     studyVintagesRepository   = new StudyVintagesRepository();
     subjectGroupsRepository   = new SubjectGroupsRepository();
     subjectsRepository        = new SubjectsRepository();
     workplacesRepository      = new WorkplacesRepository();
 }
Example #16
0
 private void teacherCreateButton_Click(object sender, EventArgs e) => new DetailedTeacherForm
 (
     null,
     SubjectsRepository.GetAll(),
     newTeacherVM =>
 {
     var newTeacherId = TeachersRepository.Add(newTeacherVM.Teacher).Id;
     TeacherSubjectRepository.AddSubjectsForTeacher(newTeacherId, newTeacherVM.SubjectIds);
     UpdateTeachersGrid();
     return(true);
 }
 ).Show();
Example #17
0
 public ICollection <Material> GetMaterialsFromSubject(string subjectName)
 {
     try
     {
         var subject = SubjectsRepository.GetList().Where(x => x.Name == subjectName).First();
         return(MaterialsRepository.GetList(subject));
     }
     catch (Exception)
     {
         return(new List <Material>());
     }
 }
Example #18
0
 public ICollection <Subject> GetSubjectsFromSpecialization(string specializationName)
 {
     try
     {
         var specialization = SpecializationsRepository.GetList().Where(x => x.Name == specializationName).First();
         return(SubjectsRepository.GetList(specialization));
     }
     catch (Exception)
     {
         return(new List <Subject>());
     }
 }
Example #19
0
 private void subjectCreateButton_Click(object sender, EventArgs e) => new DetailedSubjectForm
 (
     null,
     TeachersRepository.GetAll(),
     newSubjectVM =>
 {
     var newSubjectId = SubjectsRepository.Add(newSubjectVM.Subject).Id;
     TeacherSubjectRepository.AddTeachersForSubject(newSubjectId, newSubjectVM.TeacherIds);
     UpdateSubjectsGrid();
     return(true);
 }
 ).Show();
Example #20
0
 public UnitOfWork(Model1 dbContext)
 {
     _dbContext                 = dbContext;
     StudentRepository          = new StudentRepository(_dbContext);
     TeacherRepository          = new TeacherRepository(_dbContext);
     PrincipalRepository        = new PrincipalRepository(_dbContext);
     UserRepository             = new UserRepository(_dbContext);
     School_SubjectsRepository  = new School_SubjectsRepository(_dbContext);
     SessionRepository          = new SessionRepository(_dbContext);
     Teachers_ClassesRepository = new Teachers_ClassesRepository(_dbContext);
     dClassRepository           = new ClassRepository(_dbContext);
     SubjectsRepository         = new SubjectsRepository(_dbContext);
     //add other repositories here
 }
Example #21
0
        public void AddItemTest()
        {
            //_context.Subjects.RemoveRange(_context.Subjects);
            var repo = new SubjectsRepository(_context);
            var item = new Subject {
                Name = "Data Engineering"
            };

            repo.AddItem(item);
            string name = _context.Subjects.FirstOrDefault(x => x.Name == item.Name).Name;

            Assert.AreEqual(item.Name, name);
            _context.Subjects.Remove(item);
        }
Example #22
0
        public void GetItemTest()
        {
            //_context.Subjects.RemoveRange(_context.Subjects);
            var repo = new SubjectsRepository(_context);
            var item = new Subject {
                Name = "Automation Theory"
            };

            repo.AddItem(item);
            int Id = _context.Subjects.FirstOrDefault(x => x.Name == item.Name).Id;

            Assert.AreEqual(item.Name, repo.GetItem(Id).Name);
            _context.Subjects.Remove(item);
        }
Example #23
0
        private void FillSubjectCombo()
        {
            SubjectsRepository  subjectsRepository = new SubjectsRepository();
            List <SubjectModel> subjectModels      = subjectsRepository.GetAllSubjects();

            BindingSource bs = new BindingSource();

            bs.DataSource = subjectModels;

            cmbSubjects.ValueMember   = "SubjectID";
            cmbSubjects.DisplayMember = "SubjectName";

            cmbSubjects.SelectedValue = -1;

            cmbSubjects.DataSource = bs;
        }
Example #24
0
 static Unit()
 {
     _context = new MyAppDbContext("MyAppConnStr");
     DepartmentsRepository  = new DepartmentsRepository(_context);
     TeachersRepository     = new TeachersRepository(_context);
     SubjectsRepository     = new SubjectsRepository(_context);
     SpecialitiesRepository = new SpecialitiesRepository(_context);
     GroupsRepository       = new GroupsRepository(_context);
     PhonesRepository       = new PhonesRepository(_context);
     StudentsRepository     = new StudentsRepository(_context);
     AudiencesRepository    = new AudiencesRepository(_context);
     AudLectRepository      = new AudLectRepository(_context);
     LectionsRepository     = new LectionsRepository(_context);
     MarksRepository        = new MarksRepository(_context);
     TeachSubjRepository    = new TeachSubjRepository(_context);
 }
Example #25
0
        public void ChangeItemTest()
        {
            //_context.Subjects.RemoveRange(_context.Subjects);
            var repo = new SubjectsRepository(_context);
            var item = new Subject {
                Name = "Biology"
            };

            repo.AddItem(item);
            int Id      = _context.Subjects.FirstOrDefault(x => x.Name == item.Name).Id;
            var newitem = repo.GetItem(Id);

            newitem.Name = "Chemistry";
            repo.ChangeItem(newitem);
            Assert.AreEqual(newitem.Name, _context.Subjects.FirstOrDefault(x => x.Name == newitem.Name).Name);
            _context.Subjects.Remove(newitem);
        }
Example #26
0
        public ActionResult UpdateSubjects(SubjectsViewModel vm)
        {
            try
            {
                if (vm.Subjects != null)
                {
                    SubjectsRepository.UpdateSubjects(vm.Subjects);
                    TempData["success"] = "1";
                }
            }
            catch (Exception ex)
            {
                TempData["success"] = "0";
            }

            return(RedirectToAction("Show"));
        }
Example #27
0
 static Unit()
 {
     _context                  = new MyAppDbContext("MyAppConnStr");
     AddressesRepository       = new AddressesRepository(_context);
     ClassroomsRepository      = new ClassroomsRepository(_context);
     DepartmentsRepository     = new DepartmentsRepository(_context);
     GroupsRepository          = new GroupsRepository(_context);
     GroupTimetablesRepository = new GroupTimetablesRepository(_context);
     MarksRepository           = new MarksRepository(_context);
     PairTimetablesRepository  = new PairTimetablesRepository(_context);
     PhonesRepository          = new PhonesRepository(_context);
     SpecialitiesRepository    = new SpecialitiesRepository(_context);
     StudentsRepository        = new StudentsRepository(_context);
     SubjectsRepository        = new SubjectsRepository(_context);
     TeachSubjsRepository      = new TeachSubjsRepository(_context);
     TeachersRepository        = new TeachersRepository(_context);
     TimetablesRepository      = new TimetablesRepository(_context);
 }
Example #28
0
        public ActionResult AddSubject(SubjectsViewModel vm)
        {
            string title = vm.Title;

            try
            {
                if (title != null && title != string.Empty)
                {
                    SubjectsRepository.AddSubject(title, vm.IsZip);
                    TempData["subjectAdded"] = "1";
                }
            }
            catch (Exception ex)
            {
                TempData["subjectAdded"] = "0";
            }

            return(RedirectToAction("Show"));
        }
Example #29
0
        public void AddItemsTest()
        {
            //_context.Subjects.RemoveRange(_context.Subjects);
            var repo  = new SubjectsRepository(_context);
            var item1 = new Subject {
                Name = "Automation Theory"
            };
            var item2 = new Subject {
                Name = "Data Analysis"
            };

            Subject[] items = new Subject[] { item1, item2 };

            repo.AddItems(items);
            Assert.AreEqual(items[0].Name, _context.Subjects.FirstOrDefault(x => x.Name == "Automation Theory").Name);
            Assert.AreEqual(items[1].Name, _context.Subjects.FirstOrDefault(x => x.Name == "Data Analysis").Name);
            _context.Subjects.Remove(item1);
            _context.Subjects.Remove(item2);
        }
Example #30
0
        public void AllItemsTest()
        {
            //_context.Subjects.RemoveRange(_context.Subjects);
            var repo = new SubjectsRepository(_context);

            Assert.AreEqual(_context.Subjects.Count(), repo.AllItems.Count());
            var item1 = new Subject {
                Name = "Data Engineering"
            };
            var item2 = new Subject {
                Name = "Automation Theory"
            };

            repo.AddItem(item1);
            repo.AddItem(item2);
            Assert.AreEqual(_context.Subjects.Count(), repo.AllItems.Count());
            _context.Subjects.Remove(item1);
            _context.Subjects.Remove(item2);
        }