public override void Create(Subject subject) { if (SubjectValidation.IsValidSubject(subject)) { DataAccessProvider.ExecuteNonQuery($"INSERT INTO Subjects (SubjectName, UniversityID) " + $"values (\'{subject.SubjectName}\', " + $"{subject.UniversityId})"); } }
public override void Update(Subject subject) { if (SubjectValidation.IsValidSubject(subject) && SubjectValidation.IsValidSubjectId(subject.SubjectId)) { DataAccessProvider.ExecuteNonQuery($"UPDATE Subjects SET " + $"SubjectName = \'{subject.SubjectName}\', " + $"UniversityID = {subject.UniversityId} " + $"WHERE SubjectID = {subject.SubjectId}"); } }
private void AddSubjectButton_Click(object sender, EventArgs e) { var subjectRepository = new SubjectRepository(); var subjectName = addSubjectNameTextBox.Text; var subject = new Subject(subjectName, _universityId); if (!SubjectValidation.IsValidSubject(subject)) { return; } subjectRepository.Create(subject); RefreshForm(); }