44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using Demo.Data.Entity;
|
|
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 IGroupRepository _repositoryGroupImpl;
|
|
|
|
public GroupUseCase(IGroupRepository repositoryGroupImpl)
|
|
{
|
|
_repositoryGroupImpl = repositoryGroupImpl;
|
|
}
|
|
public bool RemoveGroupById(int groupID)
|
|
{
|
|
var group = _repositoryGroupImpl.GetAllGroup().FirstOrDefault(g => g.Id == groupID);
|
|
if (group != null)
|
|
{
|
|
_repositoryGroupImpl.RemoveGroupById(groupID);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public List<Group> GetAllGroups() => _repositoryGroupImpl.GetAllGroup()
|
|
.Select(it => new Group { Id = it.Id, Name = it.Name }).ToList();
|
|
|
|
public bool AddGroup(GroupLocalEntity group)
|
|
{
|
|
|
|
return _repositoryGroupImpl.AddGroup(group);
|
|
}
|
|
|
|
public bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup)
|
|
{
|
|
return _repositoryGroupImpl.UpdateGroupById(groupID, updatedGroup);
|
|
}
|
|
}
|
|
}
|