private void btnSave_Click(object sender, EventArgs e) { try { var score = 0; var chosenTest = cbxTest.SelectedItem.ToString(); var test = new TestManager().GetByName(Convert.ToInt32(chosenTest)); if (tbxQ1Answer.Text == test.Answer1) { score = score + 1; } if (tbxQ2Answer.Text == test.Answer2) { score = score + 1; } if (tbxQ3Answer.Text == test.Answer3) { score = score + 1; } Applicant.Score += score; Applicant.Test = Applicant.Test + $",{chosenTest}"; var manager = new ApplicantManager(); manager.Update(Applicant); MyForms.GetForm <ApplicantListForm>().LoadData(); Close(); MessageBox.Show($"{lblName.Text} got {score} right answers, his/her score is improved by {score} marks", "Result"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public async Task <IActionResult> Put([FromBody] Applicant inputApplicant) { var applicant = inputApplicant; var applicantValidator = new ApplicantValidator(); var result = await applicantValidator.ValidateAsync(applicant); if (result.IsValid) { var updatedApplicant = applicantManager.Update(applicant); if (updatedApplicant != null) { logger.Information($"updated Apllicant with Id:{applicant.ID}"); return(Ok(updatedApplicant)); } else { logger.Warning("Failed to update Applicant with Put request"); return(BadRequest()); } } else { logger.Warning("Failed to update Applicant with Put request, validation failed!"); return(BadRequest()); } }
private void btnSave_Click(object sender, EventArgs e) { try { GrabUserInput(); var manager = new ApplicantManager(); if (Mode == FormMode.CreateNew) { manager.Create(Applicant); } else { manager.Update(Applicant); } MyForms.GetForm <ApplicantListForm>().LoadData(); Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }