using Posechaemost.Data.LocalData.Entity; using Posechaemost.Data.Repository; using Posechaemost.Domain.Models; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Posechaemost.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(String name, String name1) { GroupLocalEntity? result = _repositoryGroupImpl.UpdateGroup(name); if (result == null) throw new Exception(""); Group? group = GetAllGroups().FirstOrDefault(it => it.Name == result.Name); if (group == null) throw new Exception(""); return new Group {Id = group.Id, Name = name1}; } } }