Revize 3cee56d3
Přidáno uživatelem Vojtěch Bartička před asi 2 roky(ů)
Backend/Core/Services/DocumentService/DocumentServiceEF.cs | ||
---|---|---|
12 | 12 |
using AutoMapper; |
13 | 13 |
using Models.Users; |
14 | 14 |
using Ganss.XSS; |
15 |
using Microsoft.EntityFrameworkCore; |
|
15 | 16 |
|
16 | 17 |
namespace Core.Services.DocumentService |
17 | 18 |
{ |
... | ... | |
137 | 138 |
foreach (var document in documents.GetRange(firstIndex, pageSize)) |
138 | 139 |
{ |
139 | 140 |
var annotatingUsers = databaseContext.Annotations.Where(a => a.Document == document).Select(a => a.User).ToList(); |
140 |
List<UserInfo> annotatingUsersDto = annotatingUsers.Select(a => mapper.Map<UserInfo>(a)).ToList(); |
|
141 |
List<DocumentUserInfo> annotatingUsersDto = new(); |
|
142 |
|
|
143 |
// Include annotation state |
|
144 |
foreach (var annotatingUser in annotatingUsers) |
|
145 |
{ |
|
146 |
var annotation = databaseContext.Annotations |
|
147 |
.Include(a => a.Document) |
|
148 |
.Single(a => a.Document == document && a.User == annotatingUser); |
|
149 |
var dui = mapper.Map<DocumentUserInfo>(annotatingUser); |
|
150 |
dui.State = annotation.State; |
|
151 |
annotatingUsersDto.Add(dui); |
|
152 |
} |
|
141 | 153 |
|
142 | 154 |
DocumentListInfo dai = mapper.Map<DocumentListInfo>(document); |
143 | 155 |
dai.AnnotatingUsers = annotatingUsersDto; |
Také k dispozici: Unified diff
Annotation state returned with document list info