-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jonas Bjøralt <[email protected]>
- Loading branch information
1 parent
46578db
commit d25df06
Showing
26 changed files
with
1,211 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Api.Common; | ||
using Database.DatabaseContext; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Caching.Memory; | ||
|
||
namespace Api.Consultants; | ||
|
||
[Authorize] | ||
[Route("/v0/{orgUrlKey}/consultants")] | ||
[ApiController] | ||
public class ConsultantController : ControllerBase | ||
{ | ||
|
||
private readonly IMemoryCache _cache; | ||
private readonly ApplicationContext _context; | ||
|
||
public ConsultantController(ApplicationContext context, IMemoryCache cache) | ||
{ | ||
_context = context; | ||
_cache = cache; | ||
} | ||
|
||
|
||
[HttpGet] | ||
public ActionResult<SingleConsultantReadModel> Get([FromRoute] string orgUrlKey, | ||
[FromQuery(Name = "Email")] string? email = "") | ||
{ | ||
var service = new StorageService(_cache, _context); | ||
|
||
var consultant = service.GetConsultantByEmail(orgUrlKey, email ?? ""); | ||
|
||
|
||
if (consultant is null) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
return Ok( new SingleConsultantReadModel(consultant)); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Core.DomainModels; | ||
|
||
namespace Api.Consultants; | ||
|
||
public record SingleConsultantReadModel([property: Required] int Id, | ||
[property: Required] string Name, | ||
[property: Required] string Email, | ||
[property: Required] List<string> Competences, | ||
[property: Required] string Department, | ||
[property: Required] int YearsOfExperience, | ||
[property: Required] Degree Degree) | ||
|
||
{ | ||
public SingleConsultantReadModel(Consultant consultant) | ||
: this( | ||
consultant.Id, | ||
consultant.Name, | ||
consultant.Email, | ||
consultant.Competences.Select(c => c.Name).ToList(), | ||
consultant.Department.Name, | ||
consultant.YearsOfExperience, | ||
consultant.Degree ?? Degree.Master | ||
) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.