I need this code to not add the draft document to the list if the loged in user is not the documents author.
Should it work?
- var listofdocuments = dbContext.Documents.ToList();
- var filtered = new List<Document> () ;
-
- foreach (var document in listofdocuments)
- {
- if (document.IsDraft)
- {
- if(document.Author == User.FindFirst(ClaimTypes.NameIdentifier).Value)
- {
- filtered.Add(document);
- }
- else
- break;
-
- }
- filtered.Add(document);
- }