Demo/Data/Repository/GroupRepositoryImpl.cs

37 lines
1.0 KiB
C#
Raw Normal View History

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
{
public class GroupRepositoryImpl
{
public GroupRepositoryImpl() {
GetAllGroups = LocalStaticData.groups;
}
public List<GroupLocalEntity> GetAllGroups
{ get; set; }
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];
}
public GroupLocalEntity? CreateGroup(GroupLocalEntity groupCreateLocalEntity) {
if (GetAllGroups.Any(x => x.Id == groupCreateLocalEntity.Id)) return null;
GetAllGroups.Add(groupCreateLocalEntity);
return groupCreateLocalEntity;
}
}
}