Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 85b8834f

Přidáno uživatelem Vojtěch Bartička před asi 2 roky(ů)

Added info about final annotation to GET /documents

Zobrazit rozdíly:

Backend/Core/Services/DocumentService/DocumentServiceEF.cs
139 139
            {
140 140
                var annotatingUsers = databaseContext.Annotations.Where(a => a.Document == document).Select(a => a.User).ToList();
141 141
                List<DocumentUserInfo> annotatingUsersDto = new();
142
               
142

  
143 143
                // Include annotation state
144 144
                foreach (var annotatingUser in annotatingUsers)
145 145
                {
......
151 151
                    annotatingUsersDto.Add(dui);
152 152
                }
153 153

  
154
                DocumentListInfo dai = mapper.Map<DocumentListInfo>(document);
155
                dai.AnnotatingUsers = annotatingUsersDto;
156
                documentInfos.Add(dai);
154
                DocumentListInfo dli = mapper.Map<DocumentListInfo>(document);
155
                dli.AnnotatingUsers = annotatingUsersDto;
156

  
157
                dli.FinalizedExists = databaseContext.FinalAnnotations.Any(fa => fa.Document == document);
158
                if (dli.FinalizedExists)
159
                {
160
                    var finalizedAnnotation = databaseContext.FinalAnnotations
161
                        .Include(fa => fa.Annotations)
162
                        .ThenInclude(a => a.User)
163
                        .Single(fa => fa.Document == document);
164

  
165
                    dli.FinalizedState = finalizedAnnotation.State;
166
                    dli.FinalAnnotations = new();
167

  
168
                    foreach (var annotation in finalizedAnnotation.Annotations)
169
                    {
170
                        dli.FinalAnnotations.Add(new()
171
                        {
172
                            AnnotationId = annotation.Id,
173
                            UserId = annotation.User.Id,
174
                            Username = annotation.User.Username,
175
                            UserFirstName = annotation.User.Name,
176
                            UserSurname = annotation.User.Surname
177
                        });
178
                    }
179

  
180
                }
181

  
182
                documentInfos.Add(dli);
157 183
            }
158 184

  
159 185
            return new DocumentListResponse()
Backend/Models/Documents/DocumentAnnotationInfo.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

  
7
namespace Models.Documents
8
{
9
    public class DocumentAnnotationInfo
10
    {
11
        public Guid AnnotationId { get; set; }
12
        public Guid UserId { get; set; }
13
        public string UserFirstName { get; set; }
14
        public string UserSurname { get; set; }
15
        public string Username { get; set; }
16
    }
17
}
Backend/Models/Documents/DocumentListInfo.cs
1
using Models.Users;
1
using Models.Enums;
2
using Models.Users;
2 3
using System;
3 4
using System.Collections.Generic;
4 5
using System.Linq;
......
7 8

  
8 9
namespace Models.Documents;
9 10

  
10
# nullable disable
11 11
public class DocumentListInfo
12 12
{
13 13
    public Guid Id { get; set; }
......
15 15
    public int Length { get; set; }
16 16
    public int RequiredAnnotations { get; set; }
17 17
    public List<DocumentUserInfo> AnnotatingUsers { get; set; } = new();
18
    public bool FinalizedExists { get; set; }
19
    public EState? FinalizedState { get; set; }
20
    public List<DocumentAnnotationInfo>? FinalAnnotations { get; set; }
18 21
}

Také k dispozici: Unified diff