surveylib/SurveyLib.Services/Services/SurveyService.cs
2025-05-20 15:59:55 +05:00

45 lines
No EOL
1.1 KiB
C#

using SurveyLib.Core.Models;
using SurveyLib.Core.Repositories;
using SurveyLib.Core.Services;
namespace SurveyLib.Services.Services;
public class SurveyService : ISurveyService
{
private readonly ISurveyRepository _surveyRepository;
public SurveyService(ISurveyRepository surveyRepository)
{
_surveyRepository = surveyRepository;
}
public async Task AddSurveyAsync(Survey survey)
{
await _surveyRepository.AddAsync(survey);
}
public async Task UpdateSurveyAsync(Survey survey)
{
await _surveyRepository.UpdateAsync(survey);
}
public async Task DeleteSurveyAsync(int id)
{
await _surveyRepository.DeleteAsync(id);
}
public async Task<IEnumerable<Survey>> GetSurveysAsync()
{
return await _surveyRepository.GetAllAsync();
}
public async Task<Survey?> GetSurveyAsync(int id)
{
return await _surveyRepository.GetByIdAsync(id);
}
public async Task<IEnumerable<Survey>> GetSurveysByUserIdAsync(int userId)
{
return await _surveyRepository.GetSurveysByUserIdAsync(userId);
}
}