Conversation
rupakkatwal
left a comment
There was a problem hiding this comment.
Nice work!
Some comments
There was a problem hiding this comment.
can also be added those properties in outgoingdto?
There was a problem hiding this comment.
In ProjectRole Update: With Update first, the foreach loop iterates over entities that might be deleted in the next step.`
Also this update make ProjectRoleRepository UpdateRangeAsync Redundant? same with other like objectives, strategy etc.
There was a problem hiding this comment.
good point on the project role, I will look into what update methods can be reduced by calling these extensions
There was a problem hiding this comment.
Curious,Why Column field is removed from all the entities?
There was a problem hiding this comment.
the column attribute determines the name the prop has in the database. It was there before to match the column names we had, but since we are remaking the database we no longer need the column attribute
rupakkatwal
left a comment
There was a problem hiding this comment.
nice work!
Some comments and suggeastions.
| entity.ProjectId = incommingEntity.ProjectId; | ||
| entity.Name = incommingEntity.Name; | ||
| entity.Description = incommingEntity.Description; | ||
| entity.Rationale = incommingEntity.Rationale; |
There was a problem hiding this comment.
also add
entity.IconColor = incommingEntity.IconColor;
| public static async Task RemoveOutOfScopeStrategyOptions(this Issue entity, Issue incommingEntity, AppDbContext context) | ||
| { | ||
| if (!RepositoryUtilities.IsDecisionMovedOutOfStrategyTable(entity, incommingEntity)) return; | ||
| var strategyOptionsToBeRemoved = await context.StrategyOptions | ||
| .Where(e => e.Option!.Decision!.IssueId == entity.Id) | ||
| .ToListAsync(); | ||
| if (strategyOptionsToBeRemoved.Count != 0) | ||
| { | ||
| context.StrategyOptions.RemoveRange(strategyOptionsToBeRemoved); | ||
| await context.SaveChangesAsync(); | ||
| } | ||
| } | ||
|
|
||
| public static async Task RemoveOutOfScopeStrategyOptions(this Decision entity, Decision incommingEntity, AppDbContext context) | ||
| { | ||
| if (!RepositoryUtilities.IsDecisionMovedOutOfStrategyTable(entity, incommingEntity)) return; | ||
| var strategyOptionsToBeRemoved = await context.StrategyOptions | ||
| .Where(e => e.Option!.DecisionId == entity.Id) | ||
| .ToListAsync(); | ||
| if (strategyOptionsToBeRemoved.Count != 0) | ||
| { | ||
| context.StrategyOptions.RemoveRange(strategyOptionsToBeRemoved); | ||
| await context.SaveChangesAsync(); | ||
| } | ||
| } |
There was a problem hiding this comment.
| public static async Task RemoveOutOfScopeStrategyOptions(this Issue entity, Issue incommingEntity, AppDbContext context) | |
| { | |
| if (!RepositoryUtilities.IsDecisionMovedOutOfStrategyTable(entity, incommingEntity)) return; | |
| var strategyOptionsToBeRemoved = await context.StrategyOptions | |
| .Where(e => e.Option!.Decision!.IssueId == entity.Id) | |
| .ToListAsync(); | |
| if (strategyOptionsToBeRemoved.Count != 0) | |
| { | |
| context.StrategyOptions.RemoveRange(strategyOptionsToBeRemoved); | |
| await context.SaveChangesAsync(); | |
| } | |
| } | |
| public static async Task RemoveOutOfScopeStrategyOptions(this Decision entity, Decision incommingEntity, AppDbContext context) | |
| { | |
| if (!RepositoryUtilities.IsDecisionMovedOutOfStrategyTable(entity, incommingEntity)) return; | |
| var strategyOptionsToBeRemoved = await context.StrategyOptions | |
| .Where(e => e.Option!.DecisionId == entity.Id) | |
| .ToListAsync(); | |
| if (strategyOptionsToBeRemoved.Count != 0) | |
| { | |
| context.StrategyOptions.RemoveRange(strategyOptionsToBeRemoved); | |
| await context.SaveChangesAsync(); | |
| } | |
| } | |
| public static async Task RemoveOutOfScopeStrategyOptions(this Issue entity, Issue incommingEntity, AppDbContext context) | |
| { | |
| if (!RepositoryUtilities.IsDecisionMovedOutOfStrategyTable(entity, incommingEntity)) return; | |
| await RemoveStrategyOptions(context, e => e.Option!.Decision!.IssueId == entity.Id); | |
| } | |
| public static async Task RemoveOutOfScopeStrategyOptions(this Decision entity, Decision incommingEntity, AppDbContext context) | |
| { | |
| if (!RepositoryUtilities.IsDecisionMovedOutOfStrategyTable(entity, incommingEntity)) return; | |
| await RemoveStrategyOptions(context, e => e.Option!.DecisionId == entity.Id); | |
| } | |
| private static async Task RemoveStrategyOptions(AppDbContext context, Expression<Func<StrategyOption, bool>> predicate) | |
| { | |
| var strategyOptionsToBeRemoved = await context.StrategyOptions | |
| .Where(predicate) | |
| .ToListAsync(); | |
| if (strategyOptionsToBeRemoved.Count != 0) | |
| { | |
| context.StrategyOptions.RemoveRange(strategyOptionsToBeRemoved); | |
| await context.SaveChangesAsync(); | |
| } | |
| } |
|
|
||
| public static Node Update(this Node entity, Node incommingEntity, AppDbContext context) | ||
| { | ||
| entity.ProjectId = incommingEntity.ProjectId; |
There was a problem hiding this comment.
context is unused here.
| // filter out entities not found | ||
| if (entities.Count != incomingList.Count) | ||
| incomingList = incomingList.Where(e => entities.Select(x => x.Id).Contains(e.Id)).ToList(); | ||
| await entities.Update(incomingList, DbContext); |
There was a problem hiding this comment.
since the incoming list is pre-filtered to match existing entities, methods RemoveMissingFromCollectionMutate and GetEntitiesToBeAdded inside entity.update effectively does nothing (both lists have the same IDs).
found the same in OutcomeRepository,ProjectRoleRepository, and strategy Repository.
No description provided.