persistence/Persistence.Repository/Repositories/ChangeLogRepository.cs

89 lines
2.6 KiB
C#
Raw Normal View History

using Mapster;
using Microsoft.EntityFrameworkCore;
using Persistence.Database.Model;
using Persistence.Models;
using Persistence.Repositories;
namespace Persistence.Repository.Repositories;
public class ChangeLogRepository : IChangeLogRepository
{
private DbContext db;
public ChangeLogRepository(DbContext db)
{
this.db = db;
}
public Task<int> Clear(int idUser, CancellationToken token)
{
throw new NotImplementedException();
}
public Task<int> ClearAndInsertRange(int idUser, IEnumerable<IDictionary<string, object>> dtos, CancellationToken token)
{
throw new NotImplementedException();
}
public Task<IEnumerable<ChangeLogDto>> GetChangeLogForDate(DateTimeOffset? updateFrom, CancellationToken token)
{
throw new NotImplementedException();
}
public Task<IEnumerable<IDictionary<string, object>>> GetCurrent(DateTimeOffset moment, CancellationToken token)
{
throw new NotImplementedException();
}
public Task<IEnumerable<DateOnly>> GetDatesChange(CancellationToken token)
{
throw new NotImplementedException();
}
public Task<IEnumerable<IDictionary<string, object>>> GetGtDate(DateTimeOffset dateBegin, CancellationToken token)
{
throw new NotImplementedException();
}
public Task<int> InsertRange(Guid idUser, Guid idDiscriminator, IEnumerable<ChangeLogDto> dtos, CancellationToken token)
{
var entities = new List<ChangeLog>();
foreach (var dto in dtos)
{
var entity = new ChangeLog()
{
IdAuthor = idUser,
IdDiscriminator = idDiscriminator,
IdEditor = idUser,
Value = dto.Value,
Creation = DateTimeOffset.UtcNow,
IdSection = dto.IdSection,
DepthStart = dto.DepthStart,
DepthEnd = dto.DepthEnd,
};
entity.Id = idUser;
2024-11-26 10:32:44 +05:00
entities.Add(entity);
}
db.Set<ChangeLog>().AddRange(entities);
2024-11-26 10:32:44 +05:00
var result = db.SaveChangesAsync(token);
2024-11-26 10:32:44 +05:00
return result;
}
public Task<int> MarkAsDeleted(int idUser, IEnumerable<int> ids, CancellationToken token)
{
throw new NotImplementedException();
}
public Task<int> UpdateOrInsertRange(int idUser, IEnumerable<IDictionary<string, object>> dtos, CancellationToken token)
{
throw new NotImplementedException();
}
public Task<int> UpdateRange(int idUser, IEnumerable<IDictionary<string, object>> dtos, CancellationToken token)
{
throw new NotImplementedException();
}
}