using Demo.Data.LocalData; using Demo.Data.Repository; using Demo.domain.Models; using System.Collections.Generic; using System.Linq; namespace Demo.Domain.UseCase { public class GroupUseCase { private GroupRepositoryImpl _repositoryGroupImpl; public GroupUseCase(GroupRepositoryImpl repositoryGroupImpl) { _repositoryGroupImpl = repositoryGroupImpl; } public bool RemoveGroupById(int groupID) { var group = _repositoryGroupImpl.GetAllGroups.FirstOrDefault(g => g.Id == groupID); if (group != null) { _repositoryGroupImpl.RemoveGroupById(groupID); return true; } return false; } public List GetAllGroups() => _repositoryGroupImpl.GetAllGroup() .Select(it => new Group { Id = it.Id, Name = it.Name }).ToList(); public bool AddGroup(GroupLocalEntity group) { // Если метод возвращает true, то группа добавлена успешно return _repositoryGroupImpl.AddGroup(group); } public bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup) { return _repositoryGroupImpl.UpdateGroupById(groupID, updatedGroup); } } }