using System; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using Posechaemost.Data.LocalData; using Posechaemost.Data.LocalData.Entity; namespace Posechaemost.Data.Repository { public class GroupRepositoryImpl: IGroupRepository { public bool AddGroup(String name, String id) { GroupLocalEntity? groupLocal = GetAllGroups().FirstOrDefault(); // GroupLocalEntity? group = new GroupLocalEntity(); groupLocal.Name = name; groupLocal.Id = int.Parse(id); return true; } public List GetAllGroup() { return GetAllGroups(); } public List GetAllGroups() => LocalStaticData.groups; 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? groupLocal = GetAllGroups() .Where(x => x.Id == groupID).FirstOrDefault(); if (groupLocal == null) return false; return GetAllGroups().Remove(groupLocal); } 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; } } } // { // public List GetAllGroups() => LocalStaticData.groups; // public GroupLocalEntity? UpdateGroup(String name) // { // GroupLocalEntity? groupLocal = GetAllGroups() // .Where(x => x.Name == name).FirstOrDefault(); // if (groupLocal == null) return null; // groupLocal.Name = name; // return groupLocal; // } // public GroupLocalEntity? AddGroup(String name, String id) // { // GroupLocalEntity? groupLocal = GetAllGroups().FirstOrDefault(); // // GroupLocalEntity? group = new GroupLocalEntity(name, id); // groupLocal.Name = name; // groupLocal.Id = int.Parse(id); // return groupLocal; // } // }