37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
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 List<Group> GetAllGroups() => _repositoryGroupImpl.GetAllGroups
|
|
.Select(it => new Group { Id = it.Id, Name = it.Name }).ToList();
|
|
|
|
public void AddGroup(GroupLocalEntity group)
|
|
{
|
|
var newGroup = new Group { Id = group.Id, Name = group.Name };
|
|
_repositoryGroupImpl.AddGroup(group);
|
|
}
|
|
|
|
public void UpdateGroupName(int groupId, string newName)
|
|
{
|
|
var group = _repositoryGroupImpl.GetAllGroups.FirstOrDefault(g => g.Id == groupId);
|
|
if (group != null)
|
|
{
|
|
group.Name = newName;
|
|
}
|
|
}
|
|
}
|
|
}
|