DeliveryAdminWindow: Fix editing of delivery

This commit is contained in:
2024-03-19 15:36:51 +01:00
parent 1806b02039
commit a9bad4dd3f

View File

@ -5,6 +5,7 @@ using Elwig.Helpers.Weighing;
using Elwig.Models.Entities; using Elwig.Models.Entities;
using LinqKit; using LinqKit;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -1004,6 +1005,9 @@ namespace Elwig.Windows {
}; };
try { try {
if (oldDelivery != null && ctx.Entry(oldDelivery) is EntityEntry<Delivery> entry) {
entry.State = EntityState.Detached;
}
if (IsEditing || !deliveryNew) { if (IsEditing || !deliveryNew) {
ctx.Update(d); ctx.Update(d);
} else { } else {