public void AddOrUpdateDiscipline(Discipline discipline) { using (var scope = Db.BeginWork()) { var department = discipline.Department; if (department != null) { discipline.DepartmentId = department.Id; } discipline.Department = null; _disciplineRepository.AddOrUpdate(discipline); scope.SaveChanges(); discipline.Department = department; } }