Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 8c9ce202

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

Fixed issues with database OR mapping

Zobrazit rozdíly:

Backend/Core/Services/AnnotationService/AnnotationServiceEF.cs
50 50
            var users = context.Users.Where(u => request.UserIdList.Contains(u.Id)).ToList();
51 51
            foreach (var user in users)
52 52
            {
53
                var userAnnotatedDocuments = context.Annotations.Where(a => a.User == user).Select(a => a.Document).ToList();
53
                var userAnnotatedDocuments = context.Annotations
54
                    .Where(a => !(a is FinalAnnotation))
55
                    .Where(a => a.User == user)
56
                    .Select(a => a.Document)
57
                    .ToList();
54 58
                foreach (var doc in documents)
55 59
                {
56 60
                    if (userAnnotatedDocuments.Contains(doc))
......
78 82
        public AnnotationListResponse GetUserAnnotations(Guid userId)
79 83
        {
80 84
            var annotations = context.Annotations
85
                .Where(a => !(a is FinalAnnotation))
81 86
                .Where(a => a.User.Id == userId)
82 87
                .Include(a => a.Document)
83 88
                .ToList();
89

  
84 90
            var infos = new List<AnnotationListInfo>();
85 91
            foreach (var annotation in annotations)
86 92
            {
......
133 139
            if (!isFinal)
134 140
            {
135 141
                annotation = context.Annotations
142
                .Where(a => !(a is FinalAnnotation))
136 143
                .Where(a => a.Id == annotationId)
137 144
                .Include(a => a.User)
138 145
                .Include(a => a.Document).ThenInclude(d => d.Content)
......
158 165

  
159 166
            var documentContent = context.Documents.Where(d => d.Id == annotation.Document.Id).Select(d => d.Content).First();
160 167

  
161
            var tags = context.AnnotationTags.Where(at => at.Annotation.Id == annotationId)
162
                .Include(at => at.Tag)
168
            IQueryable<AnnotationTagGeneric> tagsQuery;
169
            List<AnnotationTagGeneric> tags;
170
            if (!isFinal)
171
            {
172
                tagsQuery = context.AnnotationTags.Where(at => at.Annotation.Id == annotationId);
173
            }
174
            else
175
            {
176
                tagsQuery = context.FinalAnnotationTags.Where(at => at.Annotation.Id == annotationId);
177
            }
178

  
179
            tags = tagsQuery.Include(at => at.Tag)
163 180
                .ThenInclude(t => t.Category)
164 181
                .Include(at => at.SubTag)
165 182
                .OrderBy(at => at.Position)
166
                .Select(at => at as AnnotationTagGeneric)
183
                .Select(at => at)
167 184
                .ToList();
168 185

  
169 186
            List<TagInstanceInfo> tagInstanceInfos = new();
......
259 276
            if (!isFinal)
260 277
            {
261 278
                annotation = context.Annotations
279
                    .Where(a => !(a is FinalAnnotation))
262 280
                    .Where(a => a.Id == annotationId)
263 281
                    .Include(a => a.User)
264 282
                    .Include(a => a.Document).ThenInclude(d => d.Content)
......
389 407
                if (!isFinal)
390 408
                {
391 409
                    annotation = context.Annotations
410
                    .Where(a => !(a is FinalAnnotation))
392 411
                    .Where(a => a.Id == annotationId)
393 412
                    .Include(a => a.User)
394 413
                    .Include(a => a.Document).ThenInclude(d => d.Content)
......
462 481
                if (!isFinal)
463 482
                {
464 483
                    annotation = context.Annotations
484
                    .Where(a => !(a is FinalAnnotation))
465 485
                    .Where(a => a.Id == annotationId)
466 486
                    .Include(a => a.User)
467 487
                    .Include(a => a.Document).ThenInclude(d => d.Content)
......
524 544
                if (!isFinal)
525 545
                {
526 546
                    annotation = context.Annotations
547
                    .Where(a => !(a is FinalAnnotation))
527 548
                   .Where(a => a.Id == annotationId)
528 549
                   .Include(a => a.User)
529 550
                   .Include(a => a.Document).ThenInclude(d => d.Content)
......
568 589
            }
569 590

  
570 591
            var annotations = context.Annotations
592
                .Where(a => !(a is FinalAnnotation))
571 593
                .Include(a => a.Document)
572 594
                .Where(a => a.Document == document && a.State == EState.DONE)
573 595
                .ToList();

Také k dispozici: Unified diff