presence/Data/Repository/GroupRepositoty.cs

66 lines
1.9 KiB
C#
Raw Normal View History

2024-12-06 08:51:13 +00:00
using presence.Data.LocalData.Entity;
using presence.Data.LocalData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using presence.Data.RemoteData.RemoteDatabase.DAO;
namespace presence.Data.Repository
{
public class GroupRepositoryImpl: IGroupRepository
{
public List<GroupLocalEntity> GetAllGroups() => LocalStaticData.groups;
public bool AddGroup(String name,String Id)
{
GroupLocalEntity? groupLocal = GetAllGroups().FirstOrDefault();
groupLocal.Name = name;
groupLocal.ID = int.Parse(Id);
return true;
}
public List<GroupLocalEntity> GetAllGroup()
{
return GetAllGroup();
}
public GroupLocalEntity GetGroupById(int groupID)
{
GroupLocalEntity? groupLocal = GetAllGroups()
.Where(x => x.ID == groupID).FirstOrDefault();
if (groupLocal == null) return null;
return groupLocal;
}
public bool RemoveGroupById(int groupID)
{
GroupLocalEntity? userLocal = GetAllGroups()
.Where(x => x.ID == groupID).FirstOrDefault();
if (userLocal == null) return false;
return GetAllGroups().Remove(userLocal);
}
public bool UpdateGroupById(int groupID, String name)
{
GroupLocalEntity? groupLocal = GetAllGroups()
.Where(x => x.ID == groupID).FirstOrDefault();
if (groupLocal == null) return false;
groupLocal.Name = name;
return true;
}
List<GroupDao> IGroupRepository.GetAllGroup()
{
throw new NotImplementedException();
}
GroupDao IGroupRepository.GetGroupById(int groupID)
{
throw new NotImplementedException();
}
}
}