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()

Také k dispozici: Unified diff