School Commit Init

This commit is contained in:
2024-08-31 12:07:21 +03:00
commit 0b130ee18c
2801 changed files with 4720552 additions and 0 deletions
@@ -0,0 +1,93 @@
using Microsoft.AspNetCore.Mvc;
using District3API.domain;
using District3API.RepoInterfaces;
namespace District3API.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class BlockedProfileController : Controller
{
private readonly IRepoInterface<BlockedProfile> _blockedProfileRepo;
public BlockedProfileController(IRepoInterface<BlockedProfile> blockedProfileRepo)
{
_blockedProfileRepo = blockedProfileRepo;
}
[HttpGet(Name = "GetAllBlockedProfiles")]
public IActionResult GetAll()
{
try
{
return Ok(_blockedProfileRepo.GetAll());
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("{id}", Name = "BlockedProfileGetById")]
[ProducesResponseType(200, Type = typeof(BlockedProfile))]
[ProducesResponseType(400)]
public IActionResult GetById(int id)
{
try
{
return Ok(_blockedProfileRepo.GetById(id));
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost(Name = "AddBlockedProfile")]
[ProducesResponseType(201)]
[ProducesResponseType(400)]
public IActionResult Add([FromBody] BlockedProfile blockedProfile)
{
try
{
_blockedProfileRepo.Add(blockedProfile);
return CreatedAtRoute("BlockedProfileGetById", new { id = blockedProfile.Id }, blockedProfile);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPut(Name = "UpdateBlockedProfile")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult Update([FromBody] BlockedProfile blockedProfile)
{
try
{
_blockedProfileRepo.Update(blockedProfile);
return Ok(blockedProfile);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpDelete("{id}", Name = "DeleteBlockedProfile")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult Delete([FromRoute] int id)
{
try
{
_blockedProfileRepo.Delete(id);
return NoContent();
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
}
}