Skip to content

Commit

Permalink
Add all currents to default group
Browse files Browse the repository at this point in the history
  • Loading branch information
TDroogers committed Sep 17, 2023
1 parent 000dd2b commit 8251b76
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Server/Services/DefaultScheduleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ public async Task<GetAllDefaultGroupsResponse> GetAlldefaultGroupsForUser(Guid c
ValidUntil = DateTime.MaxValue,
};
_database.UserDefaultGroups.Add(newDefaultGroup);
var currentDefaults = await _database.UserDefaultAvailables.Where(x => x.CustomerId == customerId && x.UserId == userId && x.DefaultGroupId == null).ToListAsync();
foreach (var current in currentDefaults)
{
current.DefaultGroupId = newDefaultGroup.Id;
_database.UserDefaultAvailables.Update(current);
}
await _database.SaveChangesAsync();
list.Add(newDefaultGroup.ToDefaultGroups());
}
Expand Down Expand Up @@ -164,7 +170,7 @@ public async Task<PatchDefaultScheduleForUserResponse> PatchDefaultScheduleForUs
var sw = Stopwatch.StartNew();
var result = new PatchDefaultScheduleForUserResponse();
DbRoosterDefault? dbDefault = DbQuery(body, userId);
DbUserDefaultGroup? dbGroup = await _database.UserDefaultGroups.FirstOrDefaultAsync(x=>x.CustomerId == customerId && x.UserId == userId && x.Id == body.GroupId && !x.IsDefault);
DbUserDefaultGroup? dbGroup = await _database.UserDefaultGroups.FirstOrDefaultAsync(x => x.CustomerId == customerId && x.UserId == userId && x.Id == body.GroupId && !x.IsDefault);
if (dbDefault is null)
{
sw.Stop();
Expand Down

0 comments on commit 8251b76

Please sign in to comment.