Add project files.
This commit is contained in:
		
							
								
								
									
										63
									
								
								Core.Blueprint.DAL.API/Controllers/UserProjectController.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								Core.Blueprint.DAL.API/Controllers/UserProjectController.cs
									
									
									
									
									
										Normal 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); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Sergio Matias Urquin
					Sergio Matias Urquin