move services to separate project
+ add GetByUserId methods to Survey
This commit is contained in:
parent
4caf3de6fe
commit
cc89ff818b
8 changed files with 37 additions and 3 deletions
|
|
@ -4,5 +4,5 @@ namespace SurveyLib.Core.Repositories;
|
|||
|
||||
public interface ISurveyRepository : IGenericRepository<Survey>
|
||||
{
|
||||
|
||||
Task<IEnumerable<Survey>> GetSurveysByUserIdAsync(int userId);
|
||||
}
|
||||
|
|
@ -9,4 +9,5 @@ public interface ISurveyService
|
|||
Task DeleteSurveyAsync(int id);
|
||||
Task<IEnumerable<Survey>> GetSurveysAsync();
|
||||
Task<Survey?> GetSurveyAsync(int id);
|
||||
Task<IEnumerable<Survey>> GetSurveysByUserIdAsync(int userId);
|
||||
}
|
||||
|
|
@ -41,4 +41,9 @@ public class SurveyRepository : ISurveyRepository
|
|||
_context.Surveys.Remove(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Survey>> GetSurveysByUserIdAsync(int userId)
|
||||
{
|
||||
return await _context.Surveys.Where(s => s.CreatedBy == userId).ToListAsync();
|
||||
}
|
||||
}
|
||||
|
|
@ -16,4 +16,8 @@
|
|||
<ProjectReference Include="..\SurveyLib.Core\SurveyLib.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Services\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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<IEnumerable<Survey>> GetSurveysByUserIdAsync(int userId)
|
||||
{
|
||||
return await _surveyRepository.GetSurveysByUserIdAsync(userId);
|
||||
}
|
||||
}
|
||||
13
SurveyLib.Services/SurveyLib.Services.csproj
Normal file
13
SurveyLib.Services/SurveyLib.Services.csproj
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SurveyLib.Core\SurveyLib.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue