правка замечаний

This commit is contained in:
eugeniy_ivanov 2023-01-12 10:32:54 +05:00
parent e950f40122
commit 7d9d248bcb
2 changed files with 9 additions and 6 deletions

View File

@ -21,11 +21,11 @@ namespace AsbCloudApp.Services
Task<IEnumerable<PlannedTrajectoryDto>> GetAsync(int idWell, CancellationToken token);
/// <summary>
/// Добавить строки с координатами
/// Добавить строки с координатами по одной скважине. Если в коллекции координаты для разных скважин получаем exception.
/// </summary>
/// <param name="plannedTrajectoryRows"></param>
/// <param name="token"></param>
/// <returns></returns>
/// <returns>количество записанных строк или exception с описанием</returns>
Task<int> AddRangeAsync(IEnumerable<PlannedTrajectoryDto> plannedTrajectoryRows, CancellationToken token);
/// <summary>

View File

@ -24,8 +24,10 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
}
/// <inheritdoc/>
public async Task<int> AddRangeAsync(IEnumerable<PlannedTrajectoryDto> plannedTrajectoryRows, CancellationToken token)
{
{
var idWell = plannedTrajectoryRows.First().IdWell;
if (!plannedTrajectoryRows.All(r => r.IdWell == idWell))
throw new ArgumentInvalidException("Все строки должны относиться к одной скважине", nameof(plannedTrajectoryRows));
var offsetHours = wellService.GetTimezone(idWell).Hours;
var entitys = plannedTrajectoryRows
.Select(e => Convert(e, offsetHours));
@ -73,9 +75,9 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
public async Task<IEnumerable<PlannedTrajectoryDto>> GetAsync(int idWell, CancellationToken token)
{
var well = wellService.GetOrDefault(idWell);
var offsetHours = wellService.GetTimezone(idWell).Hours;
if (well is null || well.Timezone is null)
throw new ArgumentInvalidException("idWell doesn`t exist", nameof(idWell));
var offsetHours = well.Timezone.Hours;
var query = db.PlannedTrajectories
.AsNoTracking()
.Where(x => x.IdWell == idWell);
@ -89,8 +91,9 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
/// <inheritdoc/>
public async Task<int> UpdateAsync(PlannedTrajectoryDto row, CancellationToken token)
{
var entity = Convert(row, row.Id);
{
var offsetHours = wellService.GetTimezone(row.IdWell).Hours;
var entity = Convert(row, offsetHours);
db.PlannedTrajectories.Update(entity);
return await db.SaveChangesAsync(token)
.ConfigureAwait(false);