2024-11-16 21:45:57 +00:00
|
|
|
|
using data.DAO;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace data.Repository
|
|
|
|
|
{
|
|
|
|
|
public class SQLGroupRepository : IGroupRepository
|
|
|
|
|
{
|
|
|
|
|
public readonly RemoteDatabaseContext dbContext;
|
|
|
|
|
public SQLGroupRepository(RemoteDatabaseContext remoteDatabaseContext)
|
|
|
|
|
{
|
|
|
|
|
dbContext = remoteDatabaseContext;
|
|
|
|
|
}
|
|
|
|
|
public bool addGroup(GroupDAO group)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbContext.groups.Add(group);
|
|
|
|
|
return dbContext.SaveChanges() > 1;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<GroupDAO> getAllGroup()
|
|
|
|
|
{
|
2024-11-16 21:56:50 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return dbContext.groups.ToList();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex) {
|
|
|
|
|
return new List<GroupDAO>();
|
|
|
|
|
}
|
2024-11-16 21:45:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|