2024-11-05 21:46:20 +00:00
|
|
|
|
using data.RemoteData;
|
|
|
|
|
using Data.LocalData;
|
|
|
|
|
using Data.Models;
|
|
|
|
|
using Data.RemoteData.DAO;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Data.Repository
|
|
|
|
|
{
|
|
|
|
|
public class SQLGroupRepositoryImpl:IGroupRepository
|
|
|
|
|
{
|
|
|
|
|
private readonly RemoteDataBaseContext _remoteDataBaseContext;
|
|
|
|
|
|
|
|
|
|
public SQLGroupRepositoryImpl(RemoteDataBaseContext remoteDataBaseContext) {
|
|
|
|
|
_remoteDataBaseContext = remoteDataBaseContext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool AddGroup(GroupLocalEntity newGroup)
|
|
|
|
|
{
|
|
|
|
|
GroupDao groupDao = new GroupDao { Name = newGroup.Name };
|
|
|
|
|
var result = _remoteDataBaseContext.Group.Add(groupDao);
|
|
|
|
|
if (result != null) {
|
|
|
|
|
_remoteDataBaseContext.SaveChanges();
|
|
|
|
|
return true; }
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<GroupLocalEntity> GetAllGroup()
|
|
|
|
|
{
|
2024-11-07 10:35:45 +00:00
|
|
|
|
return _remoteDataBaseContext.Group.Select(group => new GroupLocalEntity{
|
|
|
|
|
Id = group.Id,
|
|
|
|
|
Name = group.Name}
|
|
|
|
|
).ToList();
|
2024-11-05 21:46:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<GroupLocalEntity> GetAllGroups() => LocalStaticData.groups;
|
|
|
|
|
|
|
|
|
|
public GroupLocalEntity GetGroupById(int groupID)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool RemoveGroupById(int groupID)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|