From 2b9e03ec4c6fcc74b44a2914b75823ef3f64fbe2 Mon Sep 17 00:00:00 2001 From: Martyn Whitwell Date: Thu, 9 Jan 2025 15:55:19 +0000 Subject: [PATCH] rollback whitespace changes --- .../CandidatesController.cs | 62 +++++++++---------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/GetIntoTeachingApi/Controllers/TeacherTrainingAdviser/CandidatesController.cs b/GetIntoTeachingApi/Controllers/TeacherTrainingAdviser/CandidatesController.cs index 0bc80e55d..d57bcb393 100644 --- a/GetIntoTeachingApi/Controllers/TeacherTrainingAdviser/CandidatesController.cs +++ b/GetIntoTeachingApi/Controllers/TeacherTrainingAdviser/CandidatesController.cs @@ -2,15 +2,15 @@ using System.Collections.Generic; using GetIntoTeachingApi.Jobs; using GetIntoTeachingApi.Models; -using GetIntoTeachingApi.Models.Crm; +using GetIntoTeachingApi.Models.Crm; using GetIntoTeachingApi.Models.TeacherTrainingAdviser; using GetIntoTeachingApi.Services; -using GetIntoTeachingApi.Utils; +using GetIntoTeachingApi.Utils; using Hangfire; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using Swashbuckle.AspNetCore.Annotations; namespace GetIntoTeachingApi.Controllers.TeacherTrainingAdviser @@ -57,24 +57,18 @@ public IActionResult SignUp( if (!ModelState.IsValid) { return BadRequest(this.ModelState); - } - - // This is the only way we can mock/freeze the current date/time - // in contract tests (there's no other way to inject it into this class). - request.DateTimeProvider = _dateTime; + } + + // This is the only way we can mock/freeze the current date/time + // in contract tests (there's no other way to inject it into this class). + request.DateTimeProvider = _dateTime; string json = request.Candidate.SerializeChangeTracked(); - _jobClient.Enqueue((x) => x.Run(json, null)); - + _jobClient.Enqueue((x) => x.Run(json, null)); + _logger.LogInformation("TeacherTrainingAdviser - CandidatesController - Sign Up - {Client}", User.Identity.Name); return NoContent(); } - - - - - - [HttpPost] [Route("exchange_access_token/{accessToken}")] @@ -91,8 +85,8 @@ public IActionResult SignUp( public IActionResult ExchangeAccessToken( [FromRoute, SwaggerParameter("Access token (PIN code).", Required = true)] string accessToken, [FromBody, SwaggerRequestBody("Candidate access token request (must match an existing candidate).", Required = true)] ExistingCandidateRequest request) - { - request.Reference ??= User.Identity.Name; + { + request.Reference ??= User.Identity.Name; var candidate = _crm.MatchCandidate(request); @@ -102,27 +96,27 @@ public IActionResult ExchangeAccessToken( } return Ok(new TeacherTrainingAdviserSignUp(candidate)); - } - + } + [HttpPost] [Route("matchback")] - [SwaggerOperation( - Summary = "Perform a matchback operation to retrieve a pre-populated TeacherTrainingAdviserSignUp for the candidate.", - Description = @"Attempts to matchback against a known candidate and returns a pre-populated TeacherTrainingAdviser sign up if a match is found.", - OperationId = "MatchbackCandidate", + [SwaggerOperation( + Summary = "Perform a matchback operation to retrieve a pre-populated TeacherTrainingAdviserSignUp for the candidate.", + Description = @"Attempts to matchback against a known candidate and returns a pre-populated TeacherTrainingAdviser sign up if a match is found.", + OperationId = "MatchbackCandidate", Tags = new[] { "Teacher Training Adviser" })] - [ProducesResponseType(typeof(TeacherTrainingAdviserSignUp), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(TeacherTrainingAdviserSignUp), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(typeof(IDictionary), StatusCodes.Status400BadRequest)] public IActionResult Matchback([FromBody, SwaggerRequestBody("Candidate details to matchback.", Required = true)] ExistingCandidateRequest request) - { - request.Reference ??= User.Identity.Name; + { + request.Reference ??= User.Identity.Name; if (!ModelState.IsValid) { return BadRequest(ModelState); - } - + } + if (_appSettings.IsCrmIntegrationPaused) { _logger.LogInformation("TeacherTrainingAdviser - CandidatesController - potential duplicate (CRM integration paused)"); @@ -131,12 +125,12 @@ public IActionResult Matchback([FromBody, SwaggerRequestBody("Candidate details Candidate candidate; - try - { + try + { candidate = _crm.MatchCandidate(request); - } + } catch (Exception e) - { + { _logger.LogInformation("TeacherTrainingAdviser - CandidatesController - potential duplicate (CRM exception) - {Message}", e.Message); throw; } @@ -146,7 +140,7 @@ public IActionResult Matchback([FromBody, SwaggerRequestBody("Candidate details return NotFound(); } - return Ok(new TeacherTrainingAdviserSignUp(candidate)); + return Ok(new TeacherTrainingAdviserSignUp(candidate)); } } }