source: src/FinkiChattery/FinkiChattery.Persistence/Repositories/Implementations/TeacherRepo.cs@ 2a9d9d1

dev
Last change on this file since 2a9d9d1 was 2a9d9d1, checked in by Стојков Марко <mst@…>, 3 years ago

Set correct answer for question by question owner

  • Property mode set to 100644
File size: 953 bytes
Line 
1using FinkiChattery.Persistence.Context;
2using FinkiChattery.Persistence.Models;
3using FinkiChattery.Persistence.Repositories.Contracts;
4using Microsoft.EntityFrameworkCore;
5using System.Linq;
6using System.Threading.Tasks;
7
8namespace FinkiChattery.Persistence.Repositories
9{
10 public class TeacherRepo : Repository<Teacher>, ITeacherRepo
11 {
12 public TeacherRepo(ApplicationDbContext dbContext) : base(dbContext)
13 {
14 }
15
16 public async Task<TeacherSelfDto> GetTeacherSelfDto(long applicationUserId)
17 {
18 return await DbSet
19 .AsNoTracking()
20 .Include(x => x.TeacherTeams).ThenInclude(x => x.Team)
21 .Where(x => x.ApplicationUserFk == applicationUserId)
22 .Select(x => new TeacherSelfDto(x.Uid, x.ApplicationUserFk, x.TeacherTeams.Select(y => new TeacherTeamDto(y.Team.Uid, y.Team.Name))))
23 .FirstOrDefaultAsync();
24 }
25 }
26}
Note: See TracBrowser for help on using the repository browser.