Exemplo n.º 1
0
		private void AddSubjectFromList(University_Subject obj)
		{
			using (_ujc = new UniversityEntities())
			{
				var currsubj = _ujc.University_Subject.Where(s => s.Subject_ID == obj.Subject_ID).FirstOrDefault();
				var currgroup = _ujc.University_Group.Where(t => t.Group_ID == SelectedGroup.Group_ID).FirstOrDefault();
				currgroup.University_Subject.Add(currsubj);
				_ujc.SaveChanges();
				GetCurrentSubjects(SelectedGroup);
				GetAllSubjects();
			}
		}
Exemplo n.º 2
0
		private void EditSubjectFromDB(University_Subject obj)
		{
			using (_ujc = new UniversityEntities())
			{
				var subj = _ujc.University_Subject.Where(s => s.Subject_ID == obj.Subject_ID).FirstOrDefault();
				if (subj != null)
				{
					subj.Subject_Name = CurrentSubject;
					_ujc.SaveChanges();
				}
				UpdateSubjects();
			}
		}
Exemplo n.º 3
0
		private void RemoveSubjectFromList(University_Subject obj)
		{
			using (_ujc = new UniversityEntities())
			{
				var currsubj = _ujc.University_Subject.Where(s => s.Subject_ID == obj.Subject_ID).FirstOrDefault();
				var currteach = _ujc.University_Teacher.Where(t => t.Teacher_ID == SelectedTeacher.Teacher_ID).FirstOrDefault();
				currteach.University_Subject.Remove(currsubj);
				_ujc.SaveChanges();
				GetCurrentSubjects(SelectedTeacher);
				GetAllSubjects();
			}
		}
Exemplo n.º 4
0
		void DeleteSubjectFromDB(University_Subject parameter)
		{
			using (_ujc = new UniversityEntities())
			{
				var tmp = _ujc.University_Subject.Where(s => s.Subject_ID == parameter.Subject_ID).FirstOrDefault();

				if (tmp != null)
				{
					_ujc.University_Subject.Remove(tmp);
					_ujc.SaveChanges();
					SelectedSubject = null;
					UpdateSubjects();
				}
			}
		}