refact model DB and migrations

This commit is contained in:
eugeniy_ivanov 2022-12-26 19:22:29 +05:00
parent 2115a2b2c1
commit e84d45693c
3 changed files with 5 additions and 4 deletions

View File

@ -72,4 +72,5 @@ namespace AsbCloudDb.Model
[ForeignKey(nameof(IdUser))]
public virtual User User { get; set; } = null!;
}
#nullable disable
}

View File

@ -135,7 +135,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
{
var entity = o.Adapt<AsbCloudDb.Model.PlannedTrajectory>();
entity.IdWell = idWell;
entity.LoadDate = DateTime.Today.ToUtcDateTimeOffset(timezone.Hours);
entity.UpdateDate = DateTime.Today.ToUtcDateTimeOffset(timezone.Hours);
entity.IdUser = idUser;
return entity;
});

View File

@ -30,7 +30,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
var entity = dto.Adapt<AsbCloudDb.Model.PlannedTrajectory>();
entity.IdWell = idWell;
entity.Id = default;
entity.LoadDate = DateTime.Today.ToUtcDateTimeOffset(timezone.Hours);
entity.UpdateDate = DateTime.Today.ToUtcDateTimeOffset(timezone.Hours);
entity.IdUser = idUser;
db.PlannedTrajectorys.Add(entity);
}
@ -54,7 +54,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
var query = db.PlannedTrajectorys
.Where(x => x.IdWell == idWell);
var entities = await query
.OrderBy(e => e.LoadDate)
.OrderBy(e => e.UpdateDate)
.ToListAsync(token);
var result = entities
.Select(r => Convert(r));
@ -67,7 +67,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
var entity = row.Adapt<AsbCloudDb.Model.PlannedTrajectory>();
entity.IdWell = idWell;
entity.Id = idUser;
entity.LoadDate = DateTime.Today.ToUtcDateTimeOffset(timezone.Hours);
entity.UpdateDate = DateTime.Today.ToUtcDateTimeOffset(timezone.Hours);
entity.IdUser = idUser;
db.PlannedTrajectorys.Update(entity);
return await db.SaveChangesAsync(token)