2024-10-17 16:08:02 +00:00
|
|
|
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<Group> GetAllGroups() => _repositoryGroupImpl.GetAllGroups()
|
|
|
|
.Select(it => new Group { Id = it.Id, Name = it.Name}).ToList();
|
|
|
|
|
2024-10-18 08:27:50 +00:00
|
|
|
public Group UpdateGroupName(String name, String name1) {
|
|
|
|
GroupLocalEntity? result = _repositoryGroupImpl.UpdateGroup(name);
|
2024-10-17 16:08:02 +00:00
|
|
|
if (result == null) throw new Exception("");
|
2024-10-18 08:27:50 +00:00
|
|
|
Group? group = GetAllGroups().FirstOrDefault(it => it.Name == result.Name);
|
2024-10-17 16:08:02 +00:00
|
|
|
if (group == null) throw new Exception("");
|
2024-10-18 08:27:50 +00:00
|
|
|
return new Group {Id = group.Id, Name = name1};
|
2024-10-17 16:08:02 +00:00
|
|
|
}
|
2024-10-18 08:43:40 +00:00
|
|
|
public GroupLocalEntity AddGroup(String name, String id)
|
|
|
|
{
|
|
|
|
return _repositoryGroupImpl.AddGroup(name, id);
|
|
|
|
}
|
2024-10-17 16:08:02 +00:00
|
|
|
}
|
|
|
|
}
|