aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Data
diff options
context:
space:
mode:
Diffstat (limited to 'src/DevHive.Data')
-rw-r--r--src/DevHive.Data/DevHiveContext.cs1
-rw-r--r--src/DevHive.Data/Interfaces/Repositories/IPostRepository.cs4
-rw-r--r--src/DevHive.Data/Repositories/PostRepository.cs14
3 files changed, 19 insertions, 0 deletions
diff --git a/src/DevHive.Data/DevHiveContext.cs b/src/DevHive.Data/DevHiveContext.cs
index 10fd004..c1bda49 100644
--- a/src/DevHive.Data/DevHiveContext.cs
+++ b/src/DevHive.Data/DevHiveContext.cs
@@ -12,6 +12,7 @@ namespace DevHive.Data
public DbSet<Technology> Technologies { get; set; }
public DbSet<Language> Languages { get; set; }
+ public DbSet<Post> Posts { get; set; }
public DbSet<Comment> Comments { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
diff --git a/src/DevHive.Data/Interfaces/Repositories/IPostRepository.cs b/src/DevHive.Data/Interfaces/Repositories/IPostRepository.cs
index 913d8c4..7a9c02e 100644
--- a/src/DevHive.Data/Interfaces/Repositories/IPostRepository.cs
+++ b/src/DevHive.Data/Interfaces/Repositories/IPostRepository.cs
@@ -9,12 +9,16 @@ namespace DevHive.Data.Interfaces.Repositories
{
Task<bool> AddCommentAsync(Comment entity);
+ Task<Post> GetPostByIssuerAndTimeCreatedAsync(Guid issuerId, DateTime timeCreated);
+
Task<Comment> GetCommentByIdAsync(Guid id);
+ Task<Comment> GetCommentByIssuerAndTimeCreatedAsync(Guid issuerId, DateTime timeCreated);
Task<bool> EditCommentAsync(Comment newEntity);
Task<bool> DeleteCommentAsync(Comment entity);
Task<bool> DoesCommentExist(Guid id);
+
Task<bool> DoesPostExist(Guid postId);
}
}
diff --git a/src/DevHive.Data/Repositories/PostRepository.cs b/src/DevHive.Data/Repositories/PostRepository.cs
index 3be14e3..c5e8569 100644
--- a/src/DevHive.Data/Repositories/PostRepository.cs
+++ b/src/DevHive.Data/Repositories/PostRepository.cs
@@ -43,6 +43,13 @@ namespace DevHive.Data.Repositories
.FindAsync(id);
}
+ public async Task<Post> GetPostByIssuerAndTimeCreatedAsync(Guid issuerId, DateTime timeCreated)
+ {
+ return await this._context.Posts
+ .FirstOrDefaultAsync(p => p.IssuerId == issuerId &&
+ p.TimeCreated == timeCreated);
+ }
+
public async Task<Comment> GetCommentByIdAsync(Guid id)
{
return await this._context
@@ -50,6 +57,13 @@ namespace DevHive.Data.Repositories
.FindAsync(id);
}
+ public async Task<Comment> GetCommentByIssuerAndTimeCreatedAsync(Guid issuerId, DateTime timeCreated)
+ {
+ return await this._context.Comments
+ .FirstOrDefaultAsync(p => p.IssuerId == issuerId &&
+ p.TimeCreated == timeCreated);
+ }
+
//Update
public async Task<bool> EditAsync(Post newPost)
{