updating installations with new order numbers automatically updates the ordernumber2installation relation table
This commit is contained in:
parent
b07991e75d
commit
55628e2186
|
@ -98,6 +98,30 @@ public static class SessionMethods
|
||||||
var user = session?.User;
|
var user = session?.User;
|
||||||
|
|
||||||
var original = Db.GetInstallationById(installation?.Id);
|
var original = Db.GetInstallationById(installation?.Id);
|
||||||
|
var originalOrderNumbers = original!.GetOrderNumbers();
|
||||||
|
|
||||||
|
if (!Equals(originalOrderNumbers, installation?.OrderNumbers))
|
||||||
|
{
|
||||||
|
foreach (var orderNumber in installation!.OrderNumbers)
|
||||||
|
{
|
||||||
|
if (originalOrderNumbers.Contains(orderNumber)) continue;
|
||||||
|
var o2I = new OrderNumber2Installation
|
||||||
|
{
|
||||||
|
OrderNumber = orderNumber,
|
||||||
|
InstallationId = installation.Id
|
||||||
|
};
|
||||||
|
Db.Create(o2I);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var orderNumberOld in originalOrderNumbers)
|
||||||
|
{
|
||||||
|
if (!installation!.OrderNumbers.Contains(orderNumberOld))
|
||||||
|
{
|
||||||
|
Db.OrderNumber2Installation.Delete(i =>
|
||||||
|
i.InstallationId == installation.Id && i.OrderNumber == orderNumberOld);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return user is not null
|
return user is not null
|
||||||
&& installation is not null
|
&& installation is not null
|
||||||
|
|
|
@ -52,4 +52,9 @@ public static partial class Db
|
||||||
{
|
{
|
||||||
return Connection.Insert(folderAccess) > 0;
|
return Connection.Insert(folderAccess) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Boolean Create(OrderNumber2Installation o2i)
|
||||||
|
{
|
||||||
|
return Connection.Insert(o2i) > 0;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -100,4 +100,5 @@ public static partial class Db
|
||||||
.Select(i => i.RenewS3BucketUrl())
|
.Select(i => i.RenewS3BucketUrl())
|
||||||
.WhenAll();
|
.WhenAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ namespace InnovEnergy.App.Backend.Relations;
|
||||||
|
|
||||||
public class OrderNumber2Installation : Relation<String, Int64>
|
public class OrderNumber2Installation : Relation<String, Int64>
|
||||||
{
|
{
|
||||||
[Indexed] public String OrderNumber { get => Left ; init => Left = value;}
|
[Indexed] public String OrderNumber { get => Left ; set => Left = value;}
|
||||||
[Indexed] public Int64 InstallationId { get => Right; init => Right = value;}
|
[Indexed] public Int64 InstallationId { get => Right; set => Right = value;}
|
||||||
|
|
||||||
}
|
}
|
|
@ -34,6 +34,7 @@
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=resultset/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=resultset/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Salimax/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Salimax/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=signurl/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=signurl/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Smpt/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Trumpf/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Trumpf/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=ttyusb/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=ttyusb/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=tupled/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=tupled/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
|
Loading…
Reference in New Issue