Skip to content

Commit

Permalink
rollback whitespace changes
Browse files Browse the repository at this point in the history
  • Loading branch information
martyn-w committed Jan 9, 2025
1 parent 770af94 commit 2b9e03e
Showing 1 changed file with 28 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<UpsertCandidateJob>((x) => x.Run(json, null));

_jobClient.Enqueue<UpsertCandidateJob>((x) => x.Run(json, null));

_logger.LogInformation("TeacherTrainingAdviser - CandidatesController - Sign Up - {Client}", User.Identity.Name);

return NoContent();
}







[HttpPost]
[Route("exchange_access_token/{accessToken}")]
Expand All @@ -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);

Expand All @@ -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<string, string>), 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)");
Expand All @@ -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;
}
Expand All @@ -146,7 +140,7 @@ public IActionResult Matchback([FromBody, SwaggerRequestBody("Candidate details
return NotFound();
}

return Ok(new TeacherTrainingAdviserSignUp(candidate));
return Ok(new TeacherTrainingAdviserSignUp(candidate));
}
}
}

0 comments on commit 2b9e03e

Please sign in to comment.