blob: c65ba5e8ce498ea44d74f35b8c1d70729d013da0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
using System;
using System.Linq;
using System.Threading.Tasks;
using DevHive.Common.Models.Data;
using DevHive.Data.Models;
using Microsoft.EntityFrameworkCore;
namespace DevHive.Data.Repositories
{
public class FriendsRepository : UserRepository
{
private readonly DbContext _context;
public FriendsRepository(DbContext context)
: base(context)
{
this._context = context;
}
//Create
public async Task<bool> AddFriendAsync(User user, User friend)
{
this._context.Update(user);
user.Friends.Add(friend);
return await RepositoryMethods.SaveChangesAsync(this._context);
}
//Delete
public async Task<bool> RemoveFriendAsync(User user, User friend)
{
this._context.Update(user);
user.Friends.Remove(friend);
return await RepositoryMethods.SaveChangesAsync(this._context);
}
}
}
|