using Demo.Data.Repository; using Demo.domain.Models; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Demo.Domain.UseCase { public class GroupUseCase { private UserRepositoryImpl _repositoryUserImpl; private GroupRepositoryImpl _repositoryGroupImpl; public List GetAllGroups() => _repositoryGroupImpl.GetAllGroups() .Select(it => new Group { Id = it.Id, Name = it.Name }).ToList(); public GroupUseCase(UserRepositoryImpl repositoryImpl, GroupRepositoryImpl repositoryGroupImpl) { _repositoryUserImpl = repositoryImpl; _repositoryGroupImpl = repositoryGroupImpl; } public void AddGroup(Group group) { _repositoryGroupImpl.AddGroup(group); } public void UpdateGroupName(int groupId, string newName) { var group = _repositoryGroupImpl.GetGroupById(groupId); if (group != null) { group.Name = newName; _repositoryGroupImpl.UpdateGroup(group); } } } }