public IActionResult PostEnrollmentPoco(EnrollmentPoco enrollmentPoco) { _context.enrollment.Add(enrollmentPoco); _context.SaveChangesAsync(); return(Ok()); }
public override Task <EnrollmentReply> GetEnrollment(EnrollmentIDRequest request, ServerCallContext context) { EnrollmentPoco EnrollmentPoco = _logic.GetSingle(request.EnrollmentID); EnrollmentReply EnrollmentReply = new EnrollmentReply() { EnrollmentID = EnrollmentPoco.EnrollmentID, StudentID = EnrollmentPoco.StudentID, CourseID = EnrollmentPoco.CourseID }; return(Task.FromResult(EnrollmentReply)); }
public override Task <Empty> AddEnrollment(EnrollmentReply request, ServerCallContext context) { EnrollmentPoco EnrollmentPoco = new EnrollmentPoco() { EnrollmentID = request.EnrollmentID, StudentID = request.StudentID, CourseID = request.CourseID }; _logic.Add(EnrollmentPoco); return(Task.FromResult(new Empty())); }
public IActionResult Delete(int StudentId, int CourseId) { EnrollmentPoco res = context.Enrollments.FirstOrDefault(a => a.StudentId == StudentId && a.CourseId == CourseId); if (res != null) { context.Enrollments.Remove(res); context.SaveChanges(); return(Ok()); } else { return(NotFound()); } }
public IActionResult Create([FromBody] EnrollmentPoco item) { //this is to validate the exist StudentPoco student = context.Students.FirstOrDefault <StudentPoco>(a => a.Id == item.StudentId); CoursePoco course = context.Courses.FirstOrDefault <CoursePoco>(a => a.Id == item.CourseId); if (student != null && course != null) { context.Enrollments.Add(item); context.SaveChanges(); return(Ok()); } else //either Student or Course not found, Can't create { return(NotFound()); } }
public void Remove(int id) { EnrollmentPoco studentCourse = _eFGenericRepository.GetSingle(studentCourse => studentCourse.EnrollmentID == id); _eFGenericRepository.Remove(studentCourse); }
public void Add(EnrollmentPoco studentCourse) { _eFGenericRepository.Add(studentCourse); }
public IActionResult Post([FromBody] EnrollmentPoco studentCourse) { _enrollmentLogic.Add(studentCourse); return(Ok()); }