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
() ; - foreach (var document in listofdocuments)
- {
- if (document.IsDraft)
- {
- if(document.Author == User.FindFirst(ClaimTypes.NameIdentifier).Value)
- {
- filtered.Add(document);
- }
- else
- break;
- }
- filtered.Add(document);
- }

Sachin SinghRank #66 · 26.2K reputationPosted Mar 12, 2021, 5:38 AM EST
Rijwan AnsariRank #82 · 24.2K reputationPosted Mar 12, 2021, 12:46 PM EST
Satya KarkiRank #78 · 24.6K reputationPosted Mar 12, 2021, 12:50 PM EST
Jaimin ShethiyaRank #177 · 13.7K reputationPosted Mar 22, 2021, 12:53 AM EDT
can you please try with below code.
let me know if you have any other doubts so will definetly help you.
Thanks