Add project files.

This commit is contained in:
Sergio Matias Urquin
2025-04-29 18:39:57 -06:00
parent 116793710f
commit 6358f5f199
110 changed files with 4484 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
using Asp.Versioning;
using Core.Blueprint.DAL.Storage.Contracts;
using Core.Blueprint.Storage;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Core.Blueprint.DAL.API.Controllers
{
[ApiVersion("1.0")]
[Route("api/v{api-version:apiVersion}/[controller]")]
[Produces("application/json")]
[ApiController]
[AllowAnonymous]
public class BlobStorageController(IBlobStorageService storageService) : ControllerBase
{
[HttpPost("UploadBlobFromFileBrowser")]
[Consumes("multipart/form-data")]
public async Task<IActionResult> UploadBlobAsync([FromQuery] string blobName, IFormFile file)
{
if (file == null || file.Length == 0)
return BadRequest("No file uploaded.");
using var stream = file.OpenReadStream();
var result = await storageService.UploadBlobAsync(blobName, stream);
return Ok(result);
}
[HttpPost("UploadBlob")]
public async Task<IActionResult> UploadBlobAsync([FromBody] BlobAddDto newBlob)
{
var result = await storageService.UploadBlobAsync(newBlob);
return Ok(result);
}
[HttpGet("GetBlobList")]
public async Task<IActionResult> GetBlobsListAsync([FromQuery] string? prefix)
{
var result = await storageService.GetBlobsListAsync(prefix).ConfigureAwait(false);
return Ok(result);
}
[HttpGet("DownloadBlob")]
public IActionResult DownloadBlobAsync([FromQuery] string blobName)
{
var result = storageService.DownloadBlobAsync(blobName);
return Ok(result);
}
[HttpDelete("DeleteBlob")]
public async Task<IActionResult> DeleteFileAsync([FromQuery] string blobName)
{
var result = await storageService.DeleteBlobAsync(blobName).ConfigureAwait(false);
if (result is null) return NotFound($"Blob {blobName} doesn't exist");
return Ok(result);
}
}
}

View File

@@ -0,0 +1,44 @@
using Asp.Versioning;
using Core.Blueprint.DAL.KeyVault.Contracts;
using Core.Blueprint.KeyVault;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Core.Blueprint.DAL.API.Controllers
{
[ApiVersion("1.0")]
[Route("api/v{api-version:apiVersion}/[controller]")]
[Produces("application/json")]
[ApiController]
[AllowAnonymous]
public class KeyVaultController(IKeyVaultService service) : ControllerBase
{
[HttpPost("CreateSecret")]
public async Task<IActionResult> CreateSecret([FromBody] KeyVaultRequest newSecret, CancellationToken cancellationToken)
{
var result = await service.CreateSecretAsync(newSecret, cancellationToken);
return Ok(result);
}
[HttpGet("{secretName}/GetSecret")]
public async Task<IActionResult> GetSecret([FromRoute] string secretName, CancellationToken cancellationToken)
{
var result = await service.GetSecretAsync(secretName, cancellationToken);
return Ok(result);
}
[HttpPut("UpdateSecret")]
public async Task<IActionResult> UpdateSecret([FromBody] KeyVaultRequest newSecret, CancellationToken cancellationToken)
{
var result = await service.UpdateSecretAsync(newSecret, cancellationToken);
return Ok(result);
}
[HttpDelete("{secretName}/DeleteSecret")]
public async Task<IActionResult> DeleteSecret([FromRoute] string secretName, CancellationToken cancellationToken)
{
var result = await service.DeleteSecretAsync(secretName, cancellationToken);
return Ok(result);
}
}
}

View File

@@ -0,0 +1,67 @@
using Asp.Versioning;
using Core.Blueprint.DAL.Mongo.Contracts;
using Core.Blueprint.DAL.Mongo.Entities.Collections;
using Core.Blueprint.DAL.Mongo.Entities.Requests;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Core.Blueprint.DAL.API.Controllers
{
[ApiVersion("1.0")]
[Route("api/v{api-version:apiVersion}/[controller]")]
[Produces("application/json")]
[ApiController]
[AllowAnonymous]
public class MongoBlueprintController(IBlueprintService service) : ControllerBase
{
[HttpPost("Create")]
public async Task<IActionResult> CreateBlueprint([FromBody] BlueprintRequest entity, CancellationToken cancellationToken)
{
var result = await service.CreateBlueprint(entity, cancellationToken).ConfigureAwait(false);
return Created("CreatedWithIdAsync", result);
}
[HttpGet("GetAll")]
public async Task<IActionResult> GetEntities(CancellationToken cancellationToken)
{
var result = await service.GetAllBlueprints(cancellationToken).ConfigureAwait(false);
return Ok(result);
}
[HttpGet("{_id}/GetBy_Id")]
public async Task<IActionResult> GetBlueprint([FromRoute] string _id, CancellationToken cancellationToken)
{
var result = await service.GetBlueprintById(_id, cancellationToken).ConfigureAwait(false);
if (result == null)
{
return NotFound("Entity not found");
}
return Ok(result);
}
[HttpPut("{_id}/Update")]
public async Task<IActionResult> UpdateBlueprint([FromRoute] string _id, [FromBody] BlueprintCollection entity, CancellationToken cancellationToken)
{
if (_id != entity._Id?.ToString())
{
return BadRequest("Blueprint ID mismatch");
}
var result = await service.UpdateBlueprint(_id, entity, cancellationToken).ConfigureAwait(false);
return Ok(result);
}
[HttpDelete("{_id}/Delete")]
public async Task<IActionResult> DeleteBlueprint([FromRoute] string _id, CancellationToken cancellationToken)
{
var result = await service.DeleteBlueprint(_id, cancellationToken).ConfigureAwait(false);
if (result is null) return NotFound();
return Ok(result);
}
}
}

View File

@@ -0,0 +1,63 @@
using Asp.Versioning;
using Core.Blueprint.DAL.SQLServer.Contracts;
using Core.Blueprint.DAL.SQLServer.Entities;
using Core.Blueprint.DAL.SQLServer.Entities.Request;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Core.Blueprint.DAL.API.Controllers
{
[ApiVersion("1.0")]
[Route("api/v{api-version:apiVersion}/[controller]")]
[Produces("application/json")]
[ApiController]
[AllowAnonymous]
public class UserProjectController(IUserProjectService service) : ControllerBase
{
[HttpPost("Create")]
public async Task<ActionResult<UserProject>> CreateEntity([FromBody] UserProjectRequest request)
{
var result = await service.AddUserProject(request).ConfigureAwait(false);
return Created("CreatedWithIdAsync", result);
}
[HttpGet("GetAll")]
public async Task<ActionResult<IEnumerable<UserProject>>> GetEntities()
{
var result = await service.GetAllUserProjects().ConfigureAwait(false);
return Ok(result);
}
[HttpGet("{id}/GetById")]
public async Task<ActionResult<UserProject>> GetEntity(int id)
{
var result = await service.GetUserProjectById(id).ConfigureAwait(false);
if (result is null) return NotFound("User Project not found");
return Ok(result);
}
[HttpPut("{id}/Update")]
public async Task<ActionResult<UserProject>> UpdateEntity(int id, UserProject entity)
{
if (id != entity.Id)
{
return BadRequest("ID mismatch");
}
var result = await service.UpdateUserProject(entity).ConfigureAwait(false);
return Ok(entity);
}
[HttpDelete("{id}/Delete")]
public async Task<IActionResult> DeleteEntity(int id)
{
var result = await service.DeleteUserProject(id).ConfigureAwait(false);
if (result is null) return NotFound();
return Ok(result);
}
}
}