aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Data/Repositories
diff options
context:
space:
mode:
Diffstat (limited to 'src/DevHive.Data/Repositories')
-rw-r--r--src/DevHive.Data/Repositories/BaseRepository.cs10
-rw-r--r--src/DevHive.Data/Repositories/CommentRepository.cs2
-rw-r--r--src/DevHive.Data/Repositories/PostRepository.cs8
-rw-r--r--src/DevHive.Data/Repositories/RatingRepository.cs19
-rw-r--r--src/DevHive.Data/Repositories/RoleRepository.cs2
-rw-r--r--src/DevHive.Data/Repositories/UserRepository.cs2
6 files changed, 20 insertions, 23 deletions
diff --git a/src/DevHive.Data/Repositories/BaseRepository.cs b/src/DevHive.Data/Repositories/BaseRepository.cs
index cac802e..ece372e 100644
--- a/src/DevHive.Data/Repositories/BaseRepository.cs
+++ b/src/DevHive.Data/Repositories/BaseRepository.cs
@@ -21,7 +21,7 @@ namespace DevHive.Data.Repositories
.Set<TEntity>()
.AddAsync(entity);
- return await this.SaveChangesAsync(_context);
+ return await this.SaveChangesAsync();
}
public virtual async Task<TEntity> GetByIdAsync(Guid id)
@@ -39,19 +39,19 @@ namespace DevHive.Data.Repositories
entry.State = EntityState.Modified;
- return await this.SaveChangesAsync(_context);
+ return await this.SaveChangesAsync();
}
public virtual async Task<bool> DeleteAsync(TEntity entity)
{
this._context.Remove(entity);
- return await this.SaveChangesAsync(_context);
+ return await this.SaveChangesAsync();
}
- public virtual async Task<bool> SaveChangesAsync(DbContext context)
+ public virtual async Task<bool> SaveChangesAsync()
{
- int result = await context.SaveChangesAsync();
+ int result = await _context.SaveChangesAsync();
return result >= 1;
}
diff --git a/src/DevHive.Data/Repositories/CommentRepository.cs b/src/DevHive.Data/Repositories/CommentRepository.cs
index 8ddc628..1560c97 100644
--- a/src/DevHive.Data/Repositories/CommentRepository.cs
+++ b/src/DevHive.Data/Repositories/CommentRepository.cs
@@ -43,7 +43,7 @@ namespace DevHive.Data.Repositories
.CurrentValues
.SetValues(newEntity);
- return await this.SaveChangesAsync(this._context);
+ return await this.SaveChangesAsync();
}
#endregion
diff --git a/src/DevHive.Data/Repositories/PostRepository.cs b/src/DevHive.Data/Repositories/PostRepository.cs
index f9f2475..31eb7d0 100644
--- a/src/DevHive.Data/Repositories/PostRepository.cs
+++ b/src/DevHive.Data/Repositories/PostRepository.cs
@@ -24,7 +24,7 @@ namespace DevHive.Data.Repositories
return await this._context.Posts
.Include(x => x.Comments)
.Include(x => x.Creator)
- .Include(x => x.Rating)
+ // .Include(x => x.Rating)
.FirstOrDefaultAsync(x => x.Id == id);
}
@@ -45,7 +45,7 @@ namespace DevHive.Data.Repositories
public override async Task<bool> EditAsync(Guid id, Post newEntity)
{
Post post = await this.GetByIdAsync(id);
- var ratingId = post.RatingId;
+ // var ratingId = post.Rating.Id;
this._context
.Entry(post)
@@ -60,11 +60,11 @@ namespace DevHive.Data.Repositories
foreach(var comment in newEntity.Comments)
post.Comments.Add(comment);
- post.RatingId = ratingId;
+ // post.Rating.Id = ratingId;
this._context.Entry(post).State = EntityState.Modified;
- return await this.SaveChangesAsync(this._context);
+ return await this.SaveChangesAsync();
}
#endregion
diff --git a/src/DevHive.Data/Repositories/RatingRepository.cs b/src/DevHive.Data/Repositories/RatingRepository.cs
index 43fe90d..d676f27 100644
--- a/src/DevHive.Data/Repositories/RatingRepository.cs
+++ b/src/DevHive.Data/Repositories/RatingRepository.cs
@@ -9,29 +9,26 @@ namespace DevHive.Data.Repositories
public class RatingRepository : BaseRepository<Rating>, IRatingRepository
{
private readonly DevHiveContext _context;
+ private readonly IPostRepository _postRepository;
- public RatingRepository(DevHiveContext context)
+ public RatingRepository(DevHiveContext context, IPostRepository postRepository)
: base(context)
{
this._context = context;
+ this._postRepository = postRepository;
}
public async Task<Rating> GetByPostId(Guid postId)
{
- return await this._context.Rating
- .FirstOrDefaultAsync(x => x.Post.Id == postId);
- }
-
- public async Task<Tuple<int, int>> GetRating(Guid postId)
- {
- Rating rating = await this.GetByPostId(postId);
-
- return new Tuple<int, int>(rating.Likes, rating.Dislikes);
+ throw new NotImplementedException();
+ // return await this._context.Rating
+ // .FirstOrDefaultAsync(x => x.Post.Id == postId);
}
- public async Task<bool> HasUserRatedThisPost(Guid userId, Guid postId)
+ public async Task<int> GetRating(Guid postId)
{
throw new NotImplementedException();
+ // return (await this.GetByPostId(postId)).Rate;
}
}
}
diff --git a/src/DevHive.Data/Repositories/RoleRepository.cs b/src/DevHive.Data/Repositories/RoleRepository.cs
index 2eeb382..441efef 100644
--- a/src/DevHive.Data/Repositories/RoleRepository.cs
+++ b/src/DevHive.Data/Repositories/RoleRepository.cs
@@ -33,7 +33,7 @@ namespace DevHive.Data.Repositories
.CurrentValues
.SetValues(newEntity);
- return await this.SaveChangesAsync(this._context);
+ return await this.SaveChangesAsync();
}
#region Validations
diff --git a/src/DevHive.Data/Repositories/UserRepository.cs b/src/DevHive.Data/Repositories/UserRepository.cs
index 6ff2ffa..4bf919e 100644
--- a/src/DevHive.Data/Repositories/UserRepository.cs
+++ b/src/DevHive.Data/Repositories/UserRepository.cs
@@ -95,7 +95,7 @@ namespace DevHive.Data.Repositories
this._context.Entry(user).State = EntityState.Modified;
- return await this.SaveChangesAsync(this._context);
+ return await this.SaveChangesAsync();
}
#endregion