diff --git a/SurveyLib.Core/Repositories/ISurveyRepository.cs b/SurveyLib.Core/Repositories/ISurveyRepository.cs index bccec00..59cf04c 100644 --- a/SurveyLib.Core/Repositories/ISurveyRepository.cs +++ b/SurveyLib.Core/Repositories/ISurveyRepository.cs @@ -4,5 +4,5 @@ namespace SurveyLib.Core.Repositories; public interface ISurveyRepository : IGenericRepository { - + Task> GetSurveysByUserIdAsync(int userId); } \ No newline at end of file diff --git a/SurveyLib.Core/Services/ISurveyService.cs b/SurveyLib.Core/Services/ISurveyService.cs index c6d0b29..d848b2e 100644 --- a/SurveyLib.Core/Services/ISurveyService.cs +++ b/SurveyLib.Core/Services/ISurveyService.cs @@ -9,4 +9,5 @@ public interface ISurveyService Task DeleteSurveyAsync(int id); Task> GetSurveysAsync(); Task GetSurveyAsync(int id); + Task> GetSurveysByUserIdAsync(int userId); } \ No newline at end of file diff --git a/SurveyLib.Infrastructure.EFCore/Repositories/SurveyRepository.cs b/SurveyLib.Infrastructure.EFCore/Repositories/SurveyRepository.cs index b4a214e..cc48ddf 100644 --- a/SurveyLib.Infrastructure.EFCore/Repositories/SurveyRepository.cs +++ b/SurveyLib.Infrastructure.EFCore/Repositories/SurveyRepository.cs @@ -41,4 +41,9 @@ public class SurveyRepository : ISurveyRepository _context.Surveys.Remove(entity); await _context.SaveChangesAsync(); } + + public async Task> GetSurveysByUserIdAsync(int userId) + { + return await _context.Surveys.Where(s => s.CreatedBy == userId).ToListAsync(); + } } \ No newline at end of file diff --git a/SurveyLib.Infrastructure.EFCore/SurveyLib.Infrastructure.EFCore.csproj b/SurveyLib.Infrastructure.EFCore/SurveyLib.Infrastructure.EFCore.csproj index 4e65a24..016f8b3 100644 --- a/SurveyLib.Infrastructure.EFCore/SurveyLib.Infrastructure.EFCore.csproj +++ b/SurveyLib.Infrastructure.EFCore/SurveyLib.Infrastructure.EFCore.csproj @@ -16,4 +16,8 @@ + + + + diff --git a/SurveyLib.Infrastructure.EFCore/Services/QuestionService.cs b/SurveyLib.Services/Services/QuestionService.cs similarity index 95% rename from SurveyLib.Infrastructure.EFCore/Services/QuestionService.cs rename to SurveyLib.Services/Services/QuestionService.cs index 795546d..e6a42dc 100644 --- a/SurveyLib.Infrastructure.EFCore/Services/QuestionService.cs +++ b/SurveyLib.Services/Services/QuestionService.cs @@ -2,7 +2,7 @@ using SurveyLib.Core.Models; using SurveyLib.Core.Repositories; using SurveyLib.Core.Services; -namespace SurveyLib.Infrastructure.EFCore.Services; +namespace SurveyLib.Services.Services; public class QuestionService : IQuestionService { diff --git a/SurveyLib.Infrastructure.EFCore/Services/SurveyService.cs b/SurveyLib.Services/Services/SurveyService.cs similarity index 84% rename from SurveyLib.Infrastructure.EFCore/Services/SurveyService.cs rename to SurveyLib.Services/Services/SurveyService.cs index 52133db..b71b6b4 100644 --- a/SurveyLib.Infrastructure.EFCore/Services/SurveyService.cs +++ b/SurveyLib.Services/Services/SurveyService.cs @@ -2,7 +2,7 @@ using SurveyLib.Core.Models; using SurveyLib.Core.Repositories; using SurveyLib.Core.Services; -namespace SurveyLib.Infrastructure.EFCore.Services; +namespace SurveyLib.Services.Services; public class SurveyService : ISurveyService { @@ -43,4 +43,9 @@ public class SurveyService : ISurveyService { return await _surveyRepository.GetByIdAsync(id); } + + public async Task> GetSurveysByUserIdAsync(int userId) + { + return await _surveyRepository.GetSurveysByUserIdAsync(userId); + } } \ No newline at end of file diff --git a/SurveyLib.Services/SurveyLib.Services.csproj b/SurveyLib.Services/SurveyLib.Services.csproj new file mode 100644 index 0000000..923fb7a --- /dev/null +++ b/SurveyLib.Services/SurveyLib.Services.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/SurveyLib.sln b/SurveyLib.sln index 8eefef0..46c7c02 100644 --- a/SurveyLib.sln +++ b/SurveyLib.sln @@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SurveyLib.Core", "SurveyLib EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SurveyLib.Infrastructure.EFCore", "SurveyLib.Infrastructure.EFCore\SurveyLib.Infrastructure.EFCore.csproj", "{57B8F7D6-53A6-41DF-961A-D5E3E7186DB7}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SurveyLib.Services", "SurveyLib.Services\SurveyLib.Services.csproj", "{C57F4551-A397-45AB-8FF6-2C6400317CC6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -18,5 +20,9 @@ Global {57B8F7D6-53A6-41DF-961A-D5E3E7186DB7}.Debug|Any CPU.Build.0 = Debug|Any CPU {57B8F7D6-53A6-41DF-961A-D5E3E7186DB7}.Release|Any CPU.ActiveCfg = Release|Any CPU {57B8F7D6-53A6-41DF-961A-D5E3E7186DB7}.Release|Any CPU.Build.0 = Release|Any CPU + {C57F4551-A397-45AB-8FF6-2C6400317CC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C57F4551-A397-45AB-8FF6-2C6400317CC6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C57F4551-A397-45AB-8FF6-2C6400317CC6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C57F4551-A397-45AB-8FF6-2C6400317CC6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal