Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using ScriptBee.Common.Web;
using ScriptBee.Common.Web.Extensions;
using ScriptBee.Domain.Model.Analysis;
using ScriptBee.Domain.Model.Project;
using ScriptBee.Service.Project.Analysis;
using ScriptBee.UseCases.Project.Analysis;
using ScriptBee.Web.Exceptions;

namespace ScriptBee.Web.EndpointDefinitions.Analysis;

Expand Down Expand Up @@ -58,20 +58,8 @@ private static async Task<DownloadResult> DownloadIndividualFile(
MediaTypeNames.Application.Octet,
namedStream.Name
),
error =>
TypedResults.NotFound(
context.ToProblemDetails(
"Analysis Not Found",
$"An analysis with the ID '{error.Id.Value}' does not exists."
)
),
error =>
TypedResults.NotFound(
context.ToProblemDetails(
"Result Not Found",
$"An analysis result with the ID '{error.Id.Value}' does not exists."
)
)
error => error.ToProblem(context),
error =>error.ToProblem(context)
);
}

Expand All @@ -96,13 +84,7 @@ private static async Task<DownloadResult> DownloadAllFiles(
MediaTypeNames.Application.Octet,
namedStream.Name
),
error =>
TypedResults.NotFound(
context.ToProblemDetails(
"Analysis Not Found",
$"An analysis with the ID '{error.Id.Value}' does not exists."
)
)
error => error.ToProblem(context)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using ScriptBee.Common.Web;
using ScriptBee.Common.Web.Extensions;
using ScriptBee.Domain.Model.Analysis;
using ScriptBee.Domain.Model.Project;
using ScriptBee.Service.Project.Analysis;
using ScriptBee.UseCases.Project.Analysis;
using ScriptBee.Web.EndpointDefinitions.Analysis.Contracts;
using ScriptBee.Web.Exceptions;

namespace ScriptBee.Web.EndpointDefinitions.Analysis;

Expand Down Expand Up @@ -51,13 +51,7 @@ private static async Task<

return result.Match<Results<Ok<WebGetAnalysisResultConsole>, NotFound<ProblemDetails>>>(
content => TypedResults.Ok(new WebGetAnalysisResultConsole(content)),
error =>
TypedResults.NotFound(
context.ToProblemDetails(
"Analysis Not Found",
$"An analysis with the ID '{error.Id.Value}' does not exists."
)
)
error =>error.ToProblem(context)
);
}

Expand All @@ -79,13 +73,7 @@ private static async Task<

return result.Match<Results<Ok<WebGetAnalysisResultRunErrors>, NotFound<ProblemDetails>>>(
results => TypedResults.Ok(WebGetAnalysisResultRunErrors.Map(results)),
error =>
TypedResults.NotFound(
context.ToProblemDetails(
"Analysis Not Found",
$"An analysis with the ID '{error.Id.Value}' does not exists."
)
)
error => error.ToProblem(context)
);
}

Expand All @@ -107,13 +95,7 @@ private static async Task<

return result.Match<Results<Ok<WebGetAnalysisResultFileList>, NotFound<ProblemDetails>>>(
files => TypedResults.Ok(WebGetAnalysisResultFileList.Map(files)),
error =>
TypedResults.NotFound(
context.ToProblemDetails(
"Analysis Not Found",
$"An analysis with the ID '{error.Id.Value}' does not exists."
)
)
error =>error.ToProblem(context)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using ScriptBee.Common.Web;
using ScriptBee.Common.Web.Extensions;
using ScriptBee.Domain.Model.Instance;
using ScriptBee.Domain.Model.Project;
using ScriptBee.Service.Project.Context;
using ScriptBee.UseCases.Project.Context;
using ScriptBee.Web.Exceptions;

namespace ScriptBee.Web.EndpointDefinitions.Context;

Expand Down Expand Up @@ -37,13 +37,7 @@ CancellationToken cancellationToken

return result.Match<Results<NoContent, NotFound<ProblemDetails>>>(
_ => TypedResults.NoContent(),
error =>
TypedResults.NotFound(
context.ToProblemDetails(
"Instance Not Found",
$"An instance with id '{error.InstanceId}' is not allocated."
)
)
error => error.ToProblem(context)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using ScriptBee.Common.Web;
using ScriptBee.Common.Web.Extensions;
using ScriptBee.Common.Web.Validation;
using ScriptBee.Domain.Model.Instance;
using ScriptBee.Domain.Model.Project;
using ScriptBee.Service.Project.Context;
using ScriptBee.UseCases.Project.Context;
using ScriptBee.Web.EndpointDefinitions.Context.Contracts;
using ScriptBee.Web.Exceptions;

namespace ScriptBee.Web.EndpointDefinitions.Context;

Expand Down Expand Up @@ -42,20 +42,8 @@ CancellationToken cancellationToken

return result.Match<Results<NoContent, NotFound<ProblemDetails>>>(
_ => TypedResults.NoContent(),
error =>
TypedResults.NotFound(
context.ToProblemDetails(
"Project Not Found",
$"A project with the ID '{error.Id.Value}' does not exists."
)
),
error =>
TypedResults.NotFound(
context.ToProblemDetails(
"Instance Not Found",
$"An instance with id '{error.InstanceId}' is not allocated."
)
)
error => error.ToProblem(context),
error =>error.ToProblem(context)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using ScriptBee.Common.Web;
using ScriptBee.Common.Web.Extensions;
using ScriptBee.Common.Web.Validation;
using ScriptBee.Domain.Model.Instance;
using ScriptBee.Domain.Model.Project;
using ScriptBee.Service.Project.Context;
using ScriptBee.UseCases.Project.Context;
using ScriptBee.Web.EndpointDefinitions.Context.Contracts;
using ScriptBee.Web.Exceptions;

namespace ScriptBee.Web.EndpointDefinitions.Context;

Expand Down Expand Up @@ -42,20 +42,8 @@ CancellationToken cancellationToken

return result.Match<Results<NoContent, NotFound<ProblemDetails>>>(
_ => TypedResults.NoContent(),
error =>
TypedResults.NotFound(
context.ToProblemDetails(
"Project Not Found",
$"A project with the ID '{error.Id.Value}' does not exists."
)
),
error =>
TypedResults.NotFound(
context.ToProblemDetails(
"Instance Not Found",
$"An instance with id '{error.InstanceId}' is not allocated."
)
)
error => error.ToProblem(context),
error => error.ToProblem(context)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using ScriptBee.Common.Web;
using ScriptBee.Common.Web.Extensions;
using ScriptBee.Domain.Model.Instance;
using ScriptBee.Domain.Model.Project;
using ScriptBee.Service.Project.Context;
using ScriptBee.UseCases.Project.Context;
using ScriptBee.Web.Exceptions;

namespace ScriptBee.Web.EndpointDefinitions.Context;

Expand Down Expand Up @@ -40,20 +40,8 @@ CancellationToken cancellationToken

return result.Match<Results<NoContent, NotFound<ProblemDetails>>>(
_ => TypedResults.NoContent(),
error =>
TypedResults.NotFound(
context.ToProblemDetails(
"Project Not Found",
$"A project with the ID '{error.Id.Value}' does not exists."
)
),
error =>
TypedResults.NotFound(
context.ToProblemDetails(
"Instance Not Found",
$"An instance with id '{error.InstanceId}' is not allocated."
)
)
error => error.ToProblem(context),
error =>error.ToProblem(context)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using ScriptBee.Common.Web;
using ScriptBee.Common.Web.Extensions;
using ScriptBee.Domain.Model.Project;
using ScriptBee.Service.Project.Analysis;
using ScriptBee.UseCases.Project.Analysis;
using ScriptBee.Web.EndpointDefinitions.Instances.Contracts;
using ScriptBee.Web.Exceptions;

namespace ScriptBee.Web.EndpointDefinitions.Instances;

Expand Down Expand Up @@ -39,13 +39,7 @@ private static async Task<AllocateInstanceType> AllocateInstance(
$"/api/projects/{projectId}/instances/{instanceInfo.Id}",
WebProjectInstance.Map(instanceInfo)
),
error =>
TypedResults.NotFound(
context.ToProblemDetails(
"Project Not Found",
$"A project with the ID '{error.Id.Value}' does not exists."
)
)
error => error.ToProblem(context)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using ScriptBee.Common.Web;
using ScriptBee.Common.Web.Extensions;
using ScriptBee.Domain.Model.File;
using ScriptBee.Domain.Model.Project;
using ScriptBee.Service.Project.Files;
using ScriptBee.UseCases.Project.Files;
using ScriptBee.Web.EndpointDefinitions.Loaders.Contracts;
using ScriptBee.Web.Exceptions;

namespace ScriptBee.Web.EndpointDefinitions.Loaders;

Expand Down Expand Up @@ -54,13 +54,7 @@ private static async Task<UploadResult> UploadLoaderFiles(
TypedResults.Ok(
new WebUploadLoaderFilesResponse(loaderId, fileData.Select(f => f.Name))
),
error =>
TypedResults.NotFound(
context.ToProblemDetails(
"Project Not Found",
$"A project with the ID '{error.Id.Value}' does not exists."
)
)
error =>error.ToProblem(context)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using ScriptBee.Common.Web;
using ScriptBee.Common.Web.Extensions;
using ScriptBee.Common.Web.Validation;
using ScriptBee.Service.Project;
using ScriptBee.UseCases.Project;
using ScriptBee.Web.EndpointDefinitions.Project.Contracts;
using ScriptBee.Web.Exceptions;

namespace ScriptBee.Web.EndpointDefinitions.Project;

Expand Down Expand Up @@ -39,13 +39,7 @@ private static async Task<
var response = WebCreateProjectResponse.Map(projectDetails);
return TypedResults.Created($"/api/projects/{response.Id}", response);
},
error =>
TypedResults.Conflict(
context.ToProblemDetails(
"Project ID Already In Use",
$"A project with the ID '{error.Id.Value}' already exists. Use a unique Project ID or update the existing project."
)
)
error => error.ToProblem(context)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using ScriptBee.Common.Web;
using ScriptBee.Common.Web.Extensions;
using ScriptBee.Domain.Model.Project;
using ScriptBee.Service.Project;
using ScriptBee.UseCases.Project;
using ScriptBee.Web.EndpointDefinitions.Project.Contracts;
using ScriptBee.Web.Exceptions;

namespace ScriptBee.Web.EndpointDefinitions.Project;

Expand Down Expand Up @@ -46,13 +46,7 @@ private static async Task<

return result.Match<Results<Ok<WebGetProjectDetailsResponse>, NotFound<ProblemDetails>>>(
projectDetails => TypedResults.Ok(WebGetProjectDetailsResponse.Map(projectDetails)),
error =>
TypedResults.NotFound(
context.ToProblemDetails(
"Project Not Found",
$"A project with the ID '{error.Id.Value}' does not exists."
)
)
error => error.ToProblem(context)
);
}
}
Loading
Loading