2024-11-25 18:11:46 +05:00
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Persistence.Database.Model;
|
|
|
|
using Persistence.Models;
|
|
|
|
using Persistence.Repositories;
|
|
|
|
|
|
|
|
namespace Persistence.API.Controllers;
|
|
|
|
|
|
|
|
[ApiController]
|
|
|
|
[Authorize]
|
|
|
|
[Route("api/[controller]")]
|
2024-11-26 10:32:44 +05:00
|
|
|
public class ChangeLogController<TDto> : ControllerBase, IChangeLogApi<TDto, ChangeLogDto<TDto>>
|
|
|
|
where TDto : class, IChangeLogDto, new()
|
2024-11-25 18:11:46 +05:00
|
|
|
{
|
2024-11-26 10:32:44 +05:00
|
|
|
private IChangeLogRepository<TDto, ChangeLogDto<TDto>> repository;
|
2024-11-25 18:11:46 +05:00
|
|
|
|
2024-11-26 10:32:44 +05:00
|
|
|
public ChangeLogController(IChangeLogRepository<TDto, ChangeLogDto<TDto>> repository)
|
2024-11-25 18:11:46 +05:00
|
|
|
{
|
|
|
|
this.repository = repository;
|
|
|
|
}
|
2024-11-26 10:32:44 +05:00
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
public async Task<ActionResult<int>> Add(TDto dto, CancellationToken token)
|
2024-11-25 18:11:46 +05:00
|
|
|
{
|
2024-11-26 10:32:44 +05:00
|
|
|
var userId = User.GetUserId<Guid>();
|
|
|
|
var result = await repository.InsertRange(userId, [dto], token);
|
2024-11-25 18:11:46 +05:00
|
|
|
|
2024-11-26 10:32:44 +05:00
|
|
|
return Ok(result);
|
2024-11-25 18:11:46 +05:00
|
|
|
}
|
|
|
|
|
2024-11-26 10:32:44 +05:00
|
|
|
[HttpPost("range")]
|
|
|
|
public Task<ActionResult<int>> AddRange(IEnumerable<TDto> dtos, CancellationToken token)
|
2024-11-25 18:11:46 +05:00
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
2024-11-26 10:32:44 +05:00
|
|
|
[HttpDelete]
|
2024-11-25 18:11:46 +05:00
|
|
|
public Task<ActionResult<int>> Delete(int id, CancellationToken token)
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
2024-11-26 10:32:44 +05:00
|
|
|
[HttpDelete("range")]
|
2024-11-25 18:11:46 +05:00
|
|
|
public Task<ActionResult<int>> DeleteRange(IEnumerable<int> ids, CancellationToken token)
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
2024-11-26 10:32:44 +05:00
|
|
|
[HttpGet]
|
|
|
|
public Task<ActionResult<IEnumerable<TDto>>> GetChangeLogCurrent(CancellationToken token)
|
2024-11-25 18:11:46 +05:00
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
2024-11-26 10:32:44 +05:00
|
|
|
[HttpGet("history")]
|
|
|
|
public Task<ActionResult<IEnumerable<ChangeLogDto<TDto>>>> GetChangeLogForDate(DateTimeOffset historyMoment, CancellationToken token)
|
2024-11-25 18:11:46 +05:00
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
2024-11-26 10:32:44 +05:00
|
|
|
[HttpPut]
|
|
|
|
public Task<ActionResult<int>> Update(TDto dto, CancellationToken token)
|
2024-11-25 18:11:46 +05:00
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
2024-11-26 10:32:44 +05:00
|
|
|
[HttpPut("range")]
|
|
|
|
public Task<ActionResult<int>> UpdateRange(IEnumerable<TDto> dtos, CancellationToken token)
|
2024-11-25 18:11:46 +05:00
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
}
|