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 GroupRepositoryImpl _repositoryGroupImpl; public GroupUseCase(GroupRepositoryImpl repositoryGroupImpl) { _repositoryGroupImpl = repositoryGroupImpl; } public List GetAllGroups() => _repositoryGroupImpl.GetAllGroups .Select(it => new Group { Id = it.Id, Name = it.Name}).ToList(); public Group UpdateGroupName(Group group) { GroupLocalEntity groupLocalEntity = new GroupLocalEntity { Id = group.Id, Name = group.Name }; GroupLocalEntity? result = _repositoryGroupImpl.UpdateGroupName(groupLocalEntity); if (result == null) { throw new Exception(""); } return new Group { Id = result.Id, Name = result.Name }; } public bool CreateGroup(Group group) { GroupLocalEntity? groupLocalEntity = new GroupLocalEntity{Id = group.Id, Name = group.Name}; _repositoryGroupImpl.CreateGroup(groupLocalEntity); if (groupLocalEntity != null) return false; return true; } } }