Skip to content

Commit 5d339e9

Browse files
committed
refactor: return group access way in update
1 parent 177bebd commit 5d339e9

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

HwProj.CoursesService/HwProj.CoursesService.API/Services/GroupsService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Linq;
22
using System.Threading.Tasks;
3+
using System.Collections.Generic;
34
using AutoMapper;
45
using HwProj.CoursesService.API.Models;
56
using HwProj.CoursesService.API.Repositories.Groups;
@@ -62,12 +63,11 @@ public async Task DeleteGroupAsync(long groupId)
6263

6364
public async Task UpdateAsync(long groupId, Group updated)
6465
{
65-
var existingGroupMates = await _groupMatesRepository
66-
.FindAll(cm => cm.GroupId == groupId)
67-
.ToArrayAsync()
68-
.ConfigureAwait(false);
66+
var groupMates = (await _groupsRepository.GetGroupsWithGroupMatesAsync(new[] { groupId }))
67+
.FirstOrDefault()
68+
.GroupMates ?? new List<GroupMate>();
6969

70-
foreach (var groupMate in existingGroupMates)
70+
foreach (var groupMate in groupMates)
7171
{
7272
await _groupMatesRepository.DeleteAsync(groupMate.Id).ConfigureAwait(false);
7373
}

0 commit comments

Comments
 (0)