public void Add(GroupSubjectTeacherRelationDTO relation) { try { ValidateModule.ValidateStudent(relation.GroupId); ValidateModule.ValidateSubject(relation.SubjectId); ValidateModule.ValidateTeacher(relation.TeacherId); GroupSubjectRelation groupSubjectRelation = AutoMap <GroupSubjectTeacherRelationDTO, GroupSubjectRelation> .Map(relation); Database.GroupSubjectRelations.Add(groupSubjectRelation); Database.Commit(); } catch (ValidationException) { throw;// new ValidationException(ex.Message, ex.Property); } }
public GroupSubjectRelation ValidateGroupSubjectTeacherRelation(int?relationId) { if (relationId == null || relationId == 0) { throw new ValidationException("Задан неверный Id связи.", ""); } GroupSubjectRelation findingRelation = _database.GroupSubjectRelations .GetById((int)relationId); try { return(ValidateGroupSubjectTeacherRelation(findingRelation)); } catch (ValidationException) { throw; } }
public GroupSubjectRelation ValidateGroupSubjectTeacherRelation(GroupSubjectRelation relation) => relation ?? throw new ValidationException("Связь не найдена", "");