completed SurveyRepository.cs
This commit is contained in:
parent
7d06084dfb
commit
960a6ce191
6 changed files with 27 additions and 21 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using SurveyLib.Core.Models;
|
||||
using SurveyLib.Core.Repositories;
|
||||
using SurveyLib.Infrastructure.EFCore.Data;
|
||||
|
|
@ -13,43 +14,46 @@ public class SurveyRepository : ISurveyRepository
|
|||
_context = context;
|
||||
}
|
||||
|
||||
public Task<Survey>? GetByIdAsync(int id)
|
||||
public async Task<Survey?> GetByIdAsync(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return await _context.Surveys.FirstOrDefaultAsync(s => s.Id == id);
|
||||
}
|
||||
|
||||
public Task<IEnumerable<Survey>> GetAllAsync()
|
||||
public async Task<IEnumerable<Survey>> GetAllAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return await _context.Surveys.ToListAsync();
|
||||
}
|
||||
|
||||
public Task AddAsync(Survey entity)
|
||||
public async Task AddAsync(Survey entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
await _context.Surveys.AddAsync(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public Task UpdateAsync(Survey entity)
|
||||
public async Task UpdateAsync(Survey entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
_context.Surveys.Update(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public Task DeleteAsync(Survey entity)
|
||||
public async Task DeleteAsync(Survey entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
_context.Surveys.Remove(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public Task<Survey?> GetWithQuestionsAsync(int surveyId)
|
||||
public async Task<Survey?> GetWithQuestionsAsync(int surveyId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return await _context.Surveys.Include(survey => survey.Questions).FirstOrDefaultAsync(s => s.Id == surveyId);
|
||||
}
|
||||
|
||||
public Task<Survey?> GetWithCompletionsAsync(int surveyId)
|
||||
public async Task<Survey?> GetWithCompletionsAsync(int surveyId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return await _context.Surveys.Include(survey => survey.Completions).FirstOrDefaultAsync(s => s.Id == surveyId);
|
||||
}
|
||||
|
||||
public Task<Survey?> FindByTitleAsync(string title)
|
||||
public async Task<IEnumerable<Survey>> FindByTitleAsync(string title)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return await _context.Surveys.Where(s => s.Title.ToLower().Contains(title.ToLower())).ToListAsync();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue