public static async Task <HttpResponseMessage> GetTestResult(int applicantInternshipId, short obtainedScore) { var webclient = new WebClient <TestModel>(Constants.BASE_URL); var applicantInternship = new ApplicantInternshipModel { Id = applicantInternshipId, Score = obtainedScore }; return(await webclient.PostAsync <ApplicantInternshipModel>(applicantInternship)); }
public void Update(int id, [FromBody] ApplicantInternshipModel value) { var existingApplicantInternship = applicantInternships.Find(id); if (existingApplicantInternship != null) { existingApplicantInternship.Score = value.Score; existingApplicantInternship.ApplicantPassedTheTest = value.ApplicantPassedTheTest; existingApplicantInternship.DateTestTaken = value.DateTestTaken; existingApplicantInternship.N_InternshipId = value.InternshipId; existingApplicantInternship.N_ApplicantId = value.ApplicantId; db.SaveChanges(); } }
public HttpResponseMessage EndTest([FromBody] ApplicantInternshipModel applicantInternship) { var minimumScore = db.TestConfigurations.FirstOrDefault().MinimumScore; var passed = applicantInternship.Score >= minimumScore; var existingApplicantInternship = db.C_ApplicantInternship.Find(applicantInternship.Id); if (existingApplicantInternship != null) { existingApplicantInternship.Score = applicantInternship.Score; existingApplicantInternship.ApplicantPassedTheTest = passed; db.SaveChanges(); } if (passed) { return(Request.CreateResponse(HttpStatusCode.Accepted)); } else { return(Request.CreateResponse(HttpStatusCode.NotAcceptable)); } }
public static C_ApplicantInternship ApplicantInternshipModelToApplicantInternship(ApplicantInternshipModel value) { return(new C_ApplicantInternship { Id = value.Id, Score = value.Score, DateTestTaken = value.DateTestTaken, ApplicantPassedTheTest = value.ApplicantPassedTheTest, N_ApplicantId = value.ApplicantId, N_InternshipId = value.InternshipId }); }
public void Add([FromBody] ApplicantInternshipModel value) { applicantInternships.Add(ApplicantInternshipConverter.ApplicantInternshipModelToApplicantInternship(value)); db.SaveChanges(); }