diff --git a/Persistence.API/Controllers/SetpointController.cs b/Persistence.API/Controllers/SetpointController.cs index 1bae2c6..42a5ff5 100644 --- a/Persistence.API/Controllers/SetpointController.cs +++ b/Persistence.API/Controllers/SetpointController.cs @@ -101,10 +101,11 @@ public class SetpointController : ControllerBase, ISetpointApi /// /// [HttpPost] - [ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)] - public async Task Add(Guid setpointKey, object newValue, Guid idUser, CancellationToken token) + [ProducesResponseType(typeof(int), (int)HttpStatusCode.Created)] + public async Task Add(Guid setpointKey, object newValue, CancellationToken token) { - await setpointRepository.Add(setpointKey, newValue, idUser, token); + var userId = User.GetUserId(); + await setpointRepository.Add(setpointKey, newValue, userId, token); return CreatedAtAction(nameof(Add), true); } diff --git a/Persistence.API/Controllers/TechMessagesController.cs b/Persistence.API/Controllers/TechMessagesController.cs index bb26c6a..d2691c1 100644 --- a/Persistence.API/Controllers/TechMessagesController.cs +++ b/Persistence.API/Controllers/TechMessagesController.cs @@ -110,12 +110,8 @@ public class TechMessagesController : ControllerBase public async Task AddRange([FromBody] IEnumerable dtos, CancellationToken token) { var userId = User.GetUserId(); - foreach (var dto in dtos) - { - dto.UserId = userId; - } - var result = await techMessagesRepository.AddRange(dtos, token); + var result = await techMessagesRepository.AddRange(dtos, userId, token); return CreatedAtAction(nameof(AddRange), result); } diff --git a/Persistence.Repository/Repositories/TechMessagesRepository.cs b/Persistence.Repository/Repositories/TechMessagesRepository.cs index 38d24e8..c838619 100644 --- a/Persistence.Repository/Repositories/TechMessagesRepository.cs +++ b/Persistence.Repository/Repositories/TechMessagesRepository.cs @@ -88,7 +88,7 @@ namespace Persistence.Repository.Repositories return result; } - public async Task AddRange(IEnumerable dtos, CancellationToken token) + public async Task AddRange(IEnumerable dtos, Guid userId, CancellationToken token) { var entities = new List(); @@ -100,6 +100,7 @@ namespace Persistence.Repository.Repositories ?? await CreateDrillingSystem(dto.System, token); entity.SystemId = systemId; + entity.UserId = userId; entities.Add(entity); } diff --git a/Persistence/API/ISetpointApi.cs b/Persistence/API/ISetpointApi.cs index 0d23d69..b1504a2 100644 --- a/Persistence/API/ISetpointApi.cs +++ b/Persistence/API/ISetpointApi.cs @@ -40,5 +40,5 @@ public interface ISetpointApi : ISyncApi /// значение /// /// - Task Add(Guid setpointKey, object newValue, Guid userId, CancellationToken token); + Task Add(Guid setpointKey, object newValue, CancellationToken token); } diff --git a/Persistence/Repositories/ITechMessagesRepository.cs b/Persistence/Repositories/ITechMessagesRepository.cs index 2ddf71c..92e8f70 100644 --- a/Persistence/Repositories/ITechMessagesRepository.cs +++ b/Persistence/Repositories/ITechMessagesRepository.cs @@ -22,7 +22,7 @@ namespace Persistence.Repositories /// /// /// - Task AddRange(IEnumerable dtos, CancellationToken token); + Task AddRange(IEnumerable dtos, Guid userId, CancellationToken token); /// /// Получение списка уникальных названий систем АБ