38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
|
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) {
|
||
|
|
||
|
GroupLocalEntity? groupLocal = GetAllGroups
|
||
|
.Where(x => x.Id == groupUpdateLocalEntity.Id).FirstOrDefault();
|
||
|
if (groupLocal == null) return null;
|
||
|
groupLocal.Name = groupUpdateLocalEntity.Name;
|
||
|
return groupLocal;
|
||
|
}
|
||
|
|
||
|
public GroupLocalEntity? CreateGroup(GroupLocalEntity groupCreateLocalEntity) {
|
||
|
|
||
|
if (GetAllGroups.Any(x => x.Id == groupCreateLocalEntity.Id)) return null;
|
||
|
|
||
|
GetAllGroups.Add(groupCreateLocalEntity);
|
||
|
return groupCreateLocalEntity;
|
||
|
}
|
||
|
}
|
||
|
}
|