Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 0ea30313

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

Added endpoint for marking annotations as done

Zobrazit rozdíly:

Backend/Core/Services/AnnotationService/AnnotationServiceEF.cs
927 927

  
928 928
            context.SaveChanges();
929 929
        }
930

  
931
        public void MarkAnnotationAsDone(Guid annotationId, Guid userId, ERole userRole, bool done)
932
        {
933
            Annotation annotation = null;
934
            try
935
            {
936
                annotation = context.Annotations
937
                   .Where(a => a.Id == annotationId)
938
                   .Include(a => a.User)
939
                   .Include(a => a.Document).ThenInclude(d => d.Content)
940
                   .First();
941

  
942
            }
943
            catch (Exception ex)
944
            {
945
                throw new InvalidOperationException("Could not find annotation");
946
            }
947

  
948

  
949
            if (userRole < ERole.ADMINISTRATOR)
950
            {
951
                if (annotation.User.Id != userId)
952
                {
953
                    throw new UnauthorizedAccessException($"User {userId} does not have assigned annotation {annotationId}");
954
                }
955
            }
956

  
957
            annotation.State = done ? EState.DONE : EState.IN_PROGRESS;
958
            context.SaveChanges();
959
        }
930 960
    }
931 961
}

Také k dispozici: Unified diff