Skip to content

Commit

Permalink
fix: use Add() instead of Update() when creating bags (#1973)
Browse files Browse the repository at this point in the history
  • Loading branch information
lodicolo authored Oct 16, 2023
1 parent 0f3aa04 commit f3a209c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Intersect.Server/Database/PlayerData/Players/Bag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public Bag(int slots)
{
SlotCount = slots;
ValidateSlots();
Save();
Save(create: true);
}

[JsonIgnore, NotMapped]
Expand Down Expand Up @@ -116,13 +116,20 @@ public static Bag GetBag(Guid id)
}
}

public void Save ()
public void Save (bool create = false)
{
try
{
using (var context = DbInterface.CreatePlayerContext(readOnly: false))
{
context.Bags.Update(this);
if (create)
{
context.Bags.Add(this);
}
else
{
context.Bags.Update(this);
}
context.ChangeTracker.DetectChanges();
context.SaveChanges();
}
Expand Down

0 comments on commit f3a209c

Please sign in to comment.