添加项目文件。
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using GroupService.Domain.Entities;
|
||||
using GroupService.Domain.IReposities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GroupService.Infrastructure.Reposities
|
||||
{
|
||||
public class GroupReposity : IGroupReposity
|
||||
{
|
||||
private readonly GroupDbContext db;
|
||||
|
||||
public GroupReposity(GroupDbContext db)
|
||||
{
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
public Group Create(Group group)
|
||||
{
|
||||
db.Groups.Add(group);
|
||||
return group;
|
||||
}
|
||||
|
||||
public async Task<Group?> FindByIdAsync(Guid id)
|
||||
{
|
||||
return await db.Groups.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Group>> FindByMasterIdAsync(Guid userId)
|
||||
{
|
||||
return await db.Groups.Where(x => x.GroupMaster == userId).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Group>> FindByNameAsync(string name)
|
||||
{
|
||||
return await db.Groups.Where(x => x.Name == name).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user