GABRIEL22
How to fix " The ConnectionString property has not been initialized." in .Net api
No, I'm using GitHub Codespaces which is a online ide. Should I set the string config in db context rather than Program.cs alone. I didnt use OnConfiguring method because I though setting the Postgres connection string in Program.cs was enough.
7 replies
How to add data into one-to-one relationship
Yes, a Subject has a single teacher, and I establish a Count function to check if a Subject already contain a Teacher, if is not, then it add the Teacher into Subject. But the problem is I'm not sure if I did ok nor how to unit test it,
50 replies
How to add data into one-to-one relationship
This is how I did: public IHttpActionResult EnrollTeacher(string id) {
var subject = _repo.GetById(id); var teacher = _repo.GetTeacherbyId(id);
if(_repo.teacherCount() > 1 && subject != null) { Console.WriteLine("Teacher already set up"); } else { subject.TeacherId = teacher.id; } return Ok(subject);
}
50 replies