Переименовать Insert на Add

This commit is contained in:
Roman Efremov 2024-12-04 14:18:57 +05:00
parent efed33e648
commit 7092324a54
16 changed files with 23 additions and 23 deletions

View File

@ -102,10 +102,10 @@ public class SetpointController : ControllerBase, ISetpointApi
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
public async Task<IActionResult> Save(Guid setpointKey, object newValue, Guid idUser, CancellationToken token) public async Task<IActionResult> Add(Guid setpointKey, object newValue, Guid idUser, CancellationToken token)
{ {
await setpointRepository.Save(setpointKey, newValue, idUser, token); await setpointRepository.Add(setpointKey, newValue, idUser, token);
return Ok(); return CreatedAtAction(nameof(Add), true);
} }
} }

View File

@ -107,7 +107,7 @@ public class TechMessagesController : ControllerBase
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[ProducesResponseType(typeof(int), (int)HttpStatusCode.Created)] [ProducesResponseType(typeof(int), (int)HttpStatusCode.Created)]
public async Task<IActionResult> InsertRange([FromBody] IEnumerable<TechMessageDto> dtos, CancellationToken token) public async Task<IActionResult> AddRange([FromBody] IEnumerable<TechMessageDto> dtos, CancellationToken token)
{ {
var userId = User.GetUserId<Guid>(); var userId = User.GetUserId<Guid>();
foreach (var dto in dtos) foreach (var dto in dtos)
@ -115,9 +115,9 @@ public class TechMessagesController : ControllerBase
dto.UserId = userId; dto.UserId = userId;
} }
var result = await techMessagesRepository.InsertRange(dtos, token); var result = await techMessagesRepository.AddRange(dtos, token);
return CreatedAtAction(nameof(InsertRange), result); return CreatedAtAction(nameof(AddRange), result);
} }
/// <summary> /// <summary>

View File

@ -66,9 +66,9 @@ public class TimeSeriesController<TDto> : ControllerBase, ITimeSeriesDataApi<TDt
/// <param name="token"></param> /// <param name="token"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<IActionResult> InsertRange(IEnumerable<TDto> dtos, CancellationToken token) public async Task<IActionResult> AddRange(IEnumerable<TDto> dtos, CancellationToken token)
{ {
var result = await timeSeriesDataRepository.InsertRange(dtos, token); var result = await timeSeriesDataRepository.AddRange(dtos, token);
return Ok(result); return Ok(result);
} }

View File

@ -32,9 +32,9 @@ public class TimestampedSetController : ControllerBase
/// <returns>кол-во затронутых записей</returns> /// <returns>кол-во затронутых записей</returns>
[HttpPost] [HttpPost]
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
public async Task<IActionResult> InsertRange([FromRoute]Guid idDiscriminator, [FromBody]IEnumerable<TimestampedSetDto> sets, CancellationToken token) public async Task<IActionResult> AddRange([FromRoute]Guid idDiscriminator, [FromBody]IEnumerable<TimestampedSetDto> sets, CancellationToken token)
{ {
var result = await repository.InsertRange(idDiscriminator, sets, token); var result = await repository.AddRange(idDiscriminator, sets, token);
return Ok(result); return Ok(result);
} }

View File

@ -88,7 +88,7 @@ namespace Persistence.Repository.Repositories
return dtos; return dtos;
} }
public async Task Save(Guid setpointKey, object newValue, Guid idUser, CancellationToken token) public async Task Add(Guid setpointKey, object newValue, Guid idUser, CancellationToken token)
{ {
var entity = new Setpoint() var entity = new Setpoint()
{ {

View File

@ -88,7 +88,7 @@ namespace Persistence.Repository.Repositories
return result; return result;
} }
public async Task<int> InsertRange(IEnumerable<TechMessageDto> dtos, CancellationToken token) public async Task<int> AddRange(IEnumerable<TechMessageDto> dtos, CancellationToken token)
{ {
var entities = new List<TechMessage>(); var entities = new List<TechMessage>();

View File

@ -48,9 +48,9 @@ public class TimeSeriesDataCachedRepository<TEntity, TDto> : TimeSeriesDataRepos
return items; return items;
} }
public override async Task<int> InsertRange(IEnumerable<TDto> dtos, CancellationToken token) public override async Task<int> AddRange(IEnumerable<TDto> dtos, CancellationToken token)
{ {
var result = await base.InsertRange(dtos, token); var result = await base.AddRange(dtos, token);
if (result > 0) if (result > 0)
{ {

View File

@ -41,7 +41,7 @@ public class TimeSeriesDataRepository<TEntity, TDto> : ITimeSeriesDataRepository
return dtos; return dtos;
} }
public virtual async Task<int> InsertRange(IEnumerable<TDto> dtos, CancellationToken token) public virtual async Task<int> AddRange(IEnumerable<TDto> dtos, CancellationToken token)
{ {
var entities = dtos.Select(d => d.Adapt<TEntity>()); var entities = dtos.Select(d => d.Adapt<TEntity>());

View File

@ -20,7 +20,7 @@ public class TimestampedSetRepository : ITimestampedSetRepository
this.db = db; this.db = db;
} }
public Task<int> InsertRange(Guid idDiscriminator, IEnumerable<TimestampedSetDto> sets, CancellationToken token) public Task<int> AddRange(Guid idDiscriminator, IEnumerable<TimestampedSetDto> sets, CancellationToken token)
{ {
var entities = sets.Select(set => new TimestampedSet(idDiscriminator, set.Timestamp.ToUniversalTime(), set.Set)); var entities = sets.Select(set => new TimestampedSet(idDiscriminator, set.Timestamp.ToUniversalTime(), set.Set));
var dbSet = db.Set<TimestampedSet>(); var dbSet = db.Set<TimestampedSet>();

View File

@ -40,5 +40,5 @@ public interface ISetpointApi : ISyncApi<SetpointLogDto>
/// <param name="newValue">значение</param> /// <param name="newValue">значение</param>
/// <param name="token"></param> /// <param name="token"></param>
/// <returns></returns> /// <returns></returns>
Task<IActionResult> Save(Guid setpointKey, object newValue, Guid userId, CancellationToken token); Task<IActionResult> Add(Guid setpointKey, object newValue, Guid userId, CancellationToken token);
} }

View File

@ -28,7 +28,7 @@ public interface ITimeSeriesDataApi<TDto> : ITimeSeriesBaseDataApi<TDto>
/// <param name="dtos"></param> /// <param name="dtos"></param>
/// <param name="token"></param> /// <param name="token"></param>
/// <returns></returns> /// <returns></returns>
Task<IActionResult> InsertRange(IEnumerable<TDto> dtos, CancellationToken token); Task<IActionResult> AddRange(IEnumerable<TDto> dtos, CancellationToken token);
} }

View File

@ -74,7 +74,7 @@ namespace Persistence.Repositories;
// throw new NotImplementedException(); // throw new NotImplementedException();
// } // }
// public async Task<int> InsertRange(int idUser, IEnumerable<TDto> dtos, CancellationToken token) // public async Task<int> AddRange(int idUser, IEnumerable<TDto> dtos, CancellationToken token)
// { // {
// using var transaction = dbContext.Database.BeginTransaction(); // using var transaction = dbContext.Database.BeginTransaction();
// try // try

View File

@ -59,5 +59,5 @@ public interface ISetpointRepository
/// <returns></returns> /// <returns></returns>
/// to do /// to do
/// id User учесть в соответствующем методе репозитория /// id User учесть в соответствующем методе репозитория
Task Save(Guid setpointKey, object newValue, Guid idUser, CancellationToken token); Task Add(Guid setpointKey, object newValue, Guid idUser, CancellationToken token);
} }

View File

@ -22,7 +22,7 @@ namespace Persistence.Repositories
/// <param name="dtos"></param> /// <param name="dtos"></param>
/// <param name="token"></param> /// <param name="token"></param>
/// <returns></returns> /// <returns></returns>
Task<int> InsertRange(IEnumerable<TechMessageDto> dtos, CancellationToken token); Task<int> AddRange(IEnumerable<TechMessageDto> dtos, CancellationToken token);
/// <summary> /// <summary>
/// Получение списка уникальных названий систем АБ /// Получение списка уникальных названий систем АБ

View File

@ -15,5 +15,5 @@ public interface ITimeSeriesDataRepository<TDto> : ISyncRepository<TDto>, ITimeS
/// <param name="dtos"></param> /// <param name="dtos"></param>
/// <param name="token"></param> /// <param name="token"></param>
/// <returns></returns> /// <returns></returns>
Task<int> InsertRange(IEnumerable<TDto> dtos, CancellationToken token); Task<int> AddRange(IEnumerable<TDto> dtos, CancellationToken token);
} }

View File

@ -55,5 +55,5 @@ public interface ITimestampedSetRepository
/// <param name="sets"></param> /// <param name="sets"></param>
/// <param name="token"></param> /// <param name="token"></param>
/// <returns></returns> /// <returns></returns>
Task<int> InsertRange(Guid idDiscriminator, IEnumerable<TimestampedSetDto> sets, CancellationToken token); Task<int> AddRange(Guid idDiscriminator, IEnumerable<TimestampedSetDto> sets, CancellationToken token);
} }