Projekt

Obecné

Profil

« Předchozí | Další » 

Revize f2275185

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

Endpoint for adding Notes to annotations in AnnotationController

Zobrazit rozdíly:

Backend/Core/Services/AnnotationService/AnnotationServiceEF.cs
97 97
            };
98 98
        }
99 99

  
100
        public void AddNoteToAnnotation(Guid annotationId, Guid userId, ERole userRole, AddNoteToAnnotationRequest request)
101
        {
102
            Annotation annotation = null;
103
            try
104
            {
105
                annotation = context.Annotations.Include(a => a.User).First(a => a.Id == annotationId);
106
            }
107
            catch (Exception)
108
            {
109
                throw new InvalidOperationException("Annotation not found");
110
            }
111

  
112
            if (userRole < ERole.ADMINISTRATOR && annotation.User.Id != userId)
113
            {
114
                throw new UnauthorizedAccessException("User does not have access to this annotation");
115
            }
116

  
117
            annotation.Note = request.Note;
118
            context.SaveChanges();
119
        }
120

  
121

  
100 122
        public AnnotationInfo GetAnnotation(Guid annotationId, Guid userId, ERole userRole)
101 123
        {
102 124
            var annotation = context.Annotations
......
227 249
            if (sanitizer.AllowedTags.Contains("script"))
228 250
            {
229 251
                sanitizer.AllowedTags.Remove("script");
230
            }   
252
            }
231 253
            if (!sanitizer.AllowedTags.Contains("style"))
232 254
            {
233 255
                sanitizer.AllowedTags.Add("style");

Také k dispozici: Unified diff