Skip to content

Commit

Permalink
Remove unecessary SetOriginalConcurrencyControlNumber method. (#4527)
Browse files Browse the repository at this point in the history
  • Loading branch information
devinleighsmith authored Dec 16, 2024
1 parent 2183180 commit 38e8fcc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 16 deletions.
12 changes: 0 additions & 12 deletions source/backend/dal/Helpers/Extensions/DbContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ namespace Pims.Dal.Helpers.Extensions
/// </summary>
public static class DbContextExtensions
{
/// <summary>
/// When manipulating entities it is necessary to reset the original value for 'ConcurrencyControlNumber' so that concurrency checking can occur.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="context"></param>
/// <param name="source">The original source entity from the database.</param>
public static void SetOriginalConcurrencyControlNumber<T>(this DbContext context, T source)
where T : IBaseEntity
{
context.Entry(source).OriginalValues[nameof(IBaseEntity.ConcurrencyControlNumber)] = source.ConcurrencyControlNumber;
}

/// <summary>
/// Detach the entity from the context.
/// </summary>
Expand Down
4 changes: 0 additions & 4 deletions source/backend/dal/Repositories/UserRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,6 @@ public PimsUser UpdateWithoutSave(PimsUser update)
user.IssueDate = DateTime.UtcNow;
}

user.ConcurrencyControlNumber = update.ConcurrencyControlNumber;
this.Context.SetOriginalConcurrencyControlNumber(user);

var addRoles = update.PimsUserRoles.Except(user.PimsUserRoles, new UserRoleRoleIdComparer());
addRoles.ForEach(r => user.PimsUserRoles.Add(new PimsUserRole() { UserId = user.UserId, RoleId = r.RoleId }));
var removeRoles = user.PimsUserRoles.Except(update.PimsUserRoles, new UserRoleRoleIdComparer());
Expand Down Expand Up @@ -511,7 +508,6 @@ public void Delete(PimsUser delete)
.FirstOrDefault(u => u.UserId == delete.UserId) ?? throw new KeyNotFoundException();

user.ConcurrencyControlNumber = delete.ConcurrencyControlNumber;
this.Context.SetOriginalConcurrencyControlNumber(user);

user.PimsUserRoles.ForEach(ur => this.Context.Remove(ur));
user.PimsUserRoles.Clear();
Expand Down

0 comments on commit 38e8fcc

Please sign in to comment.