Add sample in mongo and sql layers
This commit is contained in:
		| @@ -12,26 +12,26 @@ namespace Core.Blueprint.DAL.API.Controllers | ||||
|     [Produces("application/json")] | ||||
|     [ApiController] | ||||
|     [AllowAnonymous] | ||||
|     public class MongoBlueprintController(IBlueprintService service) : ControllerBase | ||||
|     public class MongoSampleController(IMongoSampleService service) : ControllerBase | ||||
|     { | ||||
|         [HttpPost("Create")] | ||||
|         public async Task<IActionResult> CreateBlueprint([FromBody] BlueprintRequest entity, CancellationToken cancellationToken) | ||||
|         public async Task<IActionResult> CreateSample([FromBody] SampleRequest entity, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.CreateBlueprint(entity, cancellationToken).ConfigureAwait(false); | ||||
|             var result = await service.CreateSample(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); | ||||
|             var result = await service.GetAllSamples(cancellationToken).ConfigureAwait(false); | ||||
|             return Ok(result); | ||||
|         } | ||||
| 
 | ||||
|         [HttpGet("{_id}/GetBy_Id")] | ||||
|         public async Task<IActionResult> GetBlueprint([FromRoute] string _id, CancellationToken cancellationToken) | ||||
|         public async Task<IActionResult> GetSample([FromRoute] string _id, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.GetBlueprintById(_id, cancellationToken).ConfigureAwait(false); | ||||
|             var result = await service.GetSampleById(_id, cancellationToken).ConfigureAwait(false); | ||||
| 
 | ||||
|             if (result == null) | ||||
|             { | ||||
| @@ -42,22 +42,22 @@ namespace Core.Blueprint.DAL.API.Controllers | ||||
|         } | ||||
| 
 | ||||
|         [HttpPut("{_id}/Update")] | ||||
|         public async Task<IActionResult> UpdateBlueprint([FromRoute] string _id, [FromBody] BlueprintCollection entity, CancellationToken cancellationToken) | ||||
|         public async Task<IActionResult> UpdateSample([FromRoute] string _id, [FromBody] SampleCollection entity, CancellationToken cancellationToken) | ||||
|         { | ||||
|             if (_id != entity._Id?.ToString()) | ||||
|             { | ||||
|                 return BadRequest("Blueprint ID mismatch"); | ||||
|                 return BadRequest("Sample ID mismatch"); | ||||
|             } | ||||
| 
 | ||||
|             var result = await service.UpdateBlueprint(_id, entity, cancellationToken).ConfigureAwait(false); | ||||
|             var result = await service.UpdateSample(_id, entity, cancellationToken).ConfigureAwait(false); | ||||
| 
 | ||||
|             return Ok(result); | ||||
|         } | ||||
| 
 | ||||
|         [HttpDelete("{_id}/Delete")] | ||||
|         public async Task<IActionResult> DeleteBlueprint([FromRoute] string _id, CancellationToken cancellationToken) | ||||
|         public async Task<IActionResult> DeleteSample([FromRoute] string _id, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.DeleteBlueprint(_id, cancellationToken).ConfigureAwait(false); | ||||
|             var result = await service.DeleteSample(_id, cancellationToken).ConfigureAwait(false); | ||||
| 
 | ||||
|             if (result is null) return NotFound(); | ||||
| 
 | ||||
| @@ -12,48 +12,48 @@ namespace Core.Blueprint.DAL.API.Controllers | ||||
|     [Produces("application/json")] | ||||
|     [ApiController] | ||||
|     [AllowAnonymous] | ||||
|     public class UserProjectController(IUserProjectService service) : ControllerBase | ||||
|     public class SqlSampleController(ISqlSampleService service) : ControllerBase | ||||
|     { | ||||
|         [HttpPost("Create")] | ||||
|         public async Task<ActionResult<UserProject>> CreateEntity([FromBody] UserProjectRequest request) | ||||
|         public async Task<ActionResult<Sample>> CreateEntity([FromBody] SampleRequest request) | ||||
|         { | ||||
|             var result = await service.AddUserProject(request).ConfigureAwait(false); | ||||
|             var result = await service.AddSample(request).ConfigureAwait(false); | ||||
|             return Created("CreatedWithIdAsync", result); | ||||
|         } | ||||
| 
 | ||||
|         [HttpGet("GetAll")] | ||||
|         public async Task<ActionResult<IEnumerable<UserProject>>> GetEntities() | ||||
|         public async Task<ActionResult<IEnumerable<Sample>>> GetEntities() | ||||
|         { | ||||
|             var result = await service.GetAllUserProjects().ConfigureAwait(false); | ||||
|             var result = await service.GetAllSamples().ConfigureAwait(false); | ||||
|             return Ok(result); | ||||
|         } | ||||
| 
 | ||||
|         [HttpGet("{id}/GetById")] | ||||
|         public async Task<ActionResult<UserProject>> GetEntity(int id) | ||||
|         public async Task<ActionResult<Sample>> GetEntity(int id) | ||||
|         { | ||||
|             var result = await service.GetUserProjectById(id).ConfigureAwait(false); | ||||
|             var result = await service.GetSampleById(id).ConfigureAwait(false); | ||||
| 
 | ||||
|             if (result is null) return NotFound("User Project not found"); | ||||
|             if (result is null) return NotFound("sample not found"); | ||||
| 
 | ||||
|             return Ok(result); | ||||
|         } | ||||
| 
 | ||||
|         [HttpPut("{id}/Update")] | ||||
|         public async Task<ActionResult<UserProject>> UpdateEntity(int id, UserProject entity) | ||||
|         public async Task<ActionResult<Sample>> UpdateEntity(int id, Sample entity) | ||||
|         { | ||||
|             if (id != entity.Id) | ||||
|             { | ||||
|                 return BadRequest("ID mismatch"); | ||||
|             } | ||||
| 
 | ||||
|             var result = await service.UpdateUserProject(entity).ConfigureAwait(false); | ||||
|             var result = await service.UpdateSample(entity).ConfigureAwait(false); | ||||
|             return Ok(entity); | ||||
|         } | ||||
| 
 | ||||
|         [HttpDelete("{id}/Delete")] | ||||
|         public async Task<IActionResult> DeleteEntity(int id) | ||||
|         { | ||||
|             var result = await service.DeleteUserProject(id).ConfigureAwait(false); | ||||
|             var result = await service.DeleteSample(id).ConfigureAwait(false); | ||||
| 
 | ||||
|             if (result is null) return NotFound(); | ||||
| 
 | ||||
| @@ -17,12 +17,12 @@ namespace Core.Blueprint.DAL.API.Extensions | ||||
|         public static IServiceCollection AddDALLayerServices(this IServiceCollection services, IConfiguration configuration) | ||||
|         { | ||||
|             //Mongo | ||||
|             services.AddScoped<IBlueprintService, BlueprintService>(); | ||||
|             services.AddScoped<CollectionRepository<BlueprintCollection>>(); | ||||
|             services.AddScoped<IMongoSampleService, MongoSampleService>(); | ||||
|             services.AddScoped<CollectionRepository<SampleCollection>>(); | ||||
|  | ||||
|             //SQL | ||||
|             services.AddDbContext<SqlServerContext>(options => options.UseSqlServer(configuration.GetConnectionString("SQLServer"))); | ||||
|             services.AddScoped<IUserProjectService, UserProjectService>(); | ||||
|             services.AddScoped<ISqlSampleService, SqlSampleService>(); | ||||
|  | ||||
|             //Storage | ||||
|             services.AddScoped<IBlobStorageService, BlobStorageService>(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Sergio Matias Urquin
					Sergio Matias Urquin