presence/Domain/UseCase/GroupUseCase.cs

48 lines
1.4 KiB
C#
Raw Normal View History

2024-12-06 08:51:13 +00:00
using presence.Data.ReportsHistory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using presence.Domain.Models;
using presence.Domain.Models.ResponseModels;
using presence.Data.LocalData.Entity;
using presence.Data.Repository;
namespace presence.Domain.UseCase
{
public class GroupUseCase
{
private readonly IGroupRepository _repositoryGroupImpl;
public GroupUseCase(IGroupRepository repositoryGroupImpl)
{
_repositoryGroupImpl = repositoryGroupImpl;
}
public List<GroupResponse> GetAllGroups() => _repositoryGroupImpl.GetAllGroup()
.Select(it => new GroupResponse { ID = it.ID, Name = it.Name }).ToList();
public bool UpdateGroupName(string id, string name)
{
return _repositoryGroupImpl.UpdateGroupById(int.Parse(id), name);
}
public bool AddGroup(string name, string id)
{
return _repositoryGroupImpl.AddGroup(name, id);
}
public Group GetGroupById(int id)
{
var group = _repositoryGroupImpl.GetGroupById(id);
if (group == null) return null;
return new Group { ID = group.ID, Name = group.Name };
}
public bool RemoveGroupById(int id)
{
return _repositoryGroupImpl.RemoveGroupById(id);
}
}
}