Skip to content

Commit

Permalink
Renamed endpoints and variables in code to "consultant" for generic u…
Browse files Browse the repository at this point in the history
…sage
  • Loading branch information
yelodevopsi committed Oct 16, 2023
1 parent 5121a98 commit 9ade500
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions backend/Api/Consultants/ConsultantController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Api.Consultants;

[Route("v0/variants")]
[Route("v0/consultants")]
[ApiController]
public class ConsultantController : ControllerBase
{
Expand Down Expand Up @@ -42,23 +42,23 @@ public ActionResult<List<ConsultantReadModel>> Get(

[HttpPost]
public async Task<Results<Created<ConsultantWriteModel>, ProblemHttpResult, ValidationProblem>> AddBasicConsultant(
[FromBody] ConsultantWriteModel basicVariant)
[FromBody] ConsultantWriteModel basicConsultant)
{
try
{
var selectedDepartment = await GetDepartmentByIdAsync(basicVariant.DepartmentId);
var selectedDepartment = await GetDepartmentByIdAsync(basicConsultant.DepartmentId);
if (selectedDepartment == null) return TypedResults.Problem("Department does not exist", statusCode: 400);

var consultantList = await GetAllConsultantsAsync(_context);
var validationResults = ConsultantValidators.ValidateUniqueness(consultantList, basicVariant);
var validationResults = ConsultantValidators.ValidateUniqueness(consultantList, basicConsultant);

if (validationResults.Count > 0) return TypedResults.ValidationProblem(validationResults);

var newConsultant = CreateConsultantFromModel(basicVariant, selectedDepartment);
var newConsultant = CreateConsultantFromModel(basicConsultant, selectedDepartment);
await AddConsultantToDatabaseAsync(_context, newConsultant);
ClearConsultantCache();

return TypedResults.Created($"/variant/{newConsultant.Id}", basicVariant);
return TypedResults.Created($"/consultant/{newConsultant.Id}", basicConsultant);
}
catch
{
Expand Down Expand Up @@ -137,13 +137,13 @@ private static async Task<List<Consultant>> GetAllConsultantsAsync(ApplicationCo
return await db.Consultant.ToListAsync();
}

private static Consultant CreateConsultantFromModel(ConsultantWriteModel basicVariant,
private static Consultant CreateConsultantFromModel(ConsultantWriteModel basicConsultant,
Department selectedDepartment)
{
return new Consultant
{
Name = basicVariant.Name,
Email = basicVariant.Email,
Name = basicConsultant.Name,
Email = basicConsultant.Email,
Department = selectedDepartment
};
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/bemanning/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fetchWithToken } from "@/data/fetchWithToken";
import { Variant } from "@/types";

export default async function Bemanning() {
const consultants = (await fetchWithToken<Variant[]>("variants")) ?? [];
const consultants = (await fetchWithToken<Variant[]>("consultants")) ?? [];

return (
<div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/data/fetchWithToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function fetchWithToken<T>(path: string): Promise<T | undefined> {

function mockedCall<T>(path: string): Promise<T> {
return new Promise((resolve) => {
if (path.includes("variants")) {
if (path.includes("consultants")) {
resolve(MockConsultants as T);
}
if (path.includes("departments")) {
Expand Down

0 comments on commit 9ade500

Please sign in to comment.