public async Task <ActionResult <StudentInternshipReview> > GetStudentInternshipReview(int studentId, int InternshipId) { List <StudentInternshipReview> studentInternshipReviews = await _context.StudentInternshipReviews.ToListAsync(); StudentInternshipReview result = null; foreach (StudentInternshipReview studentInternshipReview in studentInternshipReviews) { if (studentInternshipReview.InternshipId == InternshipId && studentInternshipReview.StudentId == studentId) { result = studentInternshipReview; } } if (result == null) { return(NotFound()); } return(result); }
public async Task <ActionResult <StudentInternshipReview> > PostStudentInternshipReview(StudentInternshipReview studentInternshipReview) { _context.StudentInternshipReviews.Add(studentInternshipReview); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (StudentInternshipReviewExists(studentInternshipReview.StudentId, studentInternshipReview.InternshipId)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetStudentInternshipReview", new { id = studentInternshipReview.StudentId }, studentInternshipReview)); }
public async Task <IActionResult> PutStudentInternshipReview(int studentId, int InternshipId, StudentInternshipReview studentInternshipReview) { if (studentId != studentInternshipReview.StudentId && InternshipId != studentInternshipReview.InternshipId) { return(BadRequest()); } _context.Entry(studentInternshipReview).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentInternshipReviewExists(studentId, InternshipId)) { return(NotFound()); } else { throw; } } return(NoContent()); }