feat: implement new order methods, transport enums, and conveyor telegram overrides
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
public void SetLeRequestDeparture(string leNo, string placeName)
|
||||
{
|
||||
using var db = _dbContextFactory.GetDbContext();
|
||||
var entry = db.Destination.GetByName(placeName);
|
||||
NullCheck(entry, typeof(Destination), placeName);
|
||||
if (!db.Le.Any(l => l.LeNo == leNo))
|
||||
{
|
||||
throw new InvalidOperationException($"LE {leNo} does not exist.");
|
||||
}
|
||||
|
||||
// only check for regular LE; NoRead can be set in any entry
|
||||
if (leNo != ConstantsCommon.ConstantsLE.NoRead)
|
||||
{
|
||||
db.Destination.GetByLeNo(leNo).ForEach(d =>
|
||||
{
|
||||
if (d.Name == placeName)
|
||||
{
|
||||
if (d.Status != DestinationStatus.LeArrived)
|
||||
{
|
||||
Log.Write(LogLevel.Error,
|
||||
$"{nameof(Le)} {leNo} is set for {nameof(Destination)} {placeName}. But {nameof(Destination.Status)} is {d.Status}.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Write(LogLevel.Error,
|
||||
$"{nameof(Le)} {leNo} is already set for {nameof(Destination)} {placeName}. {nameof(Destination.Status)} is {d.Status}. Will be deleted from {nameof(Destination)} entry");
|
||||
d.SetLeDeparted();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
db.Destination.GetByName(placeName)?.SetLeRequestDeparture(leNo);
|
||||
db.SaveChanges();
|
||||
}
|
||||
Reference in New Issue
Block a user