2024-10-16 20:15:49 +00:00
|
|
|
using Demo.Data.LocalData;
|
|
|
|
using Demo.domain.Models;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
namespace Demo.Data.Repository
|
|
|
|
{
|
2024-10-21 09:07:49 +00:00
|
|
|
public class GroupRepositoryImpl:IGroupRepository
|
2024-10-16 20:15:49 +00:00
|
|
|
{
|
|
|
|
public GroupRepositoryImpl() {
|
|
|
|
|
|
|
|
GetAllGroups = LocalStaticData.groups;
|
|
|
|
}
|
|
|
|
public List<GroupLocalEntity> GetAllGroups
|
|
|
|
{ get; set; }
|
|
|
|
|
2024-10-21 09:07:49 +00:00
|
|
|
public List<GroupLocalEntity> GetAllGroup()
|
|
|
|
{
|
|
|
|
return GetAllGroups;
|
|
|
|
}
|
|
|
|
|
2024-10-16 20:15:49 +00:00
|
|
|
public GroupLocalEntity? UpdateGroupName(GroupLocalEntity groupUpdateLocalEntity) {
|
|
|
|
|
2024-10-17 12:35:14 +00:00
|
|
|
int index = GetAllGroups.FindIndex(x => x.Id == groupUpdateLocalEntity.Id);
|
|
|
|
if (index == -1) return null;
|
|
|
|
GetAllGroups[index].Name = groupUpdateLocalEntity.Name;
|
|
|
|
return GetAllGroups[index];
|
2024-10-16 20:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public GroupLocalEntity? CreateGroup(GroupLocalEntity groupCreateLocalEntity) {
|
|
|
|
|
|
|
|
if (GetAllGroups.Any(x => x.Id == groupCreateLocalEntity.Id)) return null;
|
|
|
|
|
|
|
|
GetAllGroups.Add(groupCreateLocalEntity);
|
|
|
|
return groupCreateLocalEntity;
|
|
|
|
}
|
2024-10-21 09:07:49 +00:00
|
|
|
|
|
|
|
public bool RemoveGroupById(int groupID)
|
|
|
|
{
|
|
|
|
GroupLocalEntity? groupLocal = GetAllGroups
|
|
|
|
.Where(x => x.Id == groupID).FirstOrDefault();
|
|
|
|
if (groupLocal == null) return false;
|
|
|
|
|
|
|
|
return GetAllGroups.Remove(groupLocal);
|
|
|
|
}
|
|
|
|
|
|
|
|
public GroupLocalEntity? GetGroupById(int groupID) {
|
|
|
|
GroupLocalEntity? groupLocal = GetAllGroups
|
|
|
|
.Where(x => x.Id == groupID).FirstOrDefault();
|
|
|
|
if (groupLocal == null) return null;
|
|
|
|
|
|
|
|
return groupLocal;
|
|
|
|
}
|
2024-10-16 20:15:49 +00:00
|
|
|
}
|
|
|
|
}
|