Skip to content

Commit

Permalink
Fix change tracking issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Jul 26, 2023
1 parent 7a8809c commit a3a1ad5
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions Server/Services/DataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,16 +427,21 @@ public async Task<Result> AddOrUpdateSavedScript(SavedScript script, string user
{
using var dbContext = _appDbFactory.GetContext();

var user = await dbContext.Users.FindAsync(userId);
if (user is null)
dbContext.SavedScripts.Update(script);

if (script.Creator is null)
{
return Result.Fail("User not found.");
var user = await dbContext.Users.FindAsync(userId);
if (user is null)
{
return Result.Fail("User not found.");
}

script.CreatorId = user.Id;
script.Creator = user;
script.OrganizationID = user.OrganizationID;
}

dbContext.SavedScripts.Update(script);
script.CreatorId = user.Id;
script.Creator = user;
script.OrganizationID = user.OrganizationID;
await dbContext.SaveChangesAsync();
return Result.Ok();
}
Expand Down

0 comments on commit a3a1ad5

Please sign in to comment.