-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDocumentRoleReadStrategy.cs
More file actions
22 lines (20 loc) · 914 Bytes
/
DocumentRoleReadStrategy.cs
File metadata and controls
22 lines (20 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using DocuTest.Application.Interfaces;
using DocuTest.Shared.Enums;
using DocuTest.Shared.Interfaces;
using DocuTest.Shared.Models;
using DocuTest.Shared.Strategies;
namespace DocuTest.Application.Strategies
{
public class DocumentRoleReadStrategy : SqlStrategy<Document>, IDocumentReadStrategy
{
public DocumentRoleReadStrategy(IUserContext user) : base(
column: "DocumentTypeId",
(DocumentType.Invoice, user.InRole(Role.User, Role.Accountant, Role.Admin)),
(DocumentType.CV, user.InRole(Role.Accountant, Role.Admin)),
(DocumentType.Mail, user.InRole(Role.User, Role.Accountant)),
(DocumentType.Other, user.InRole(Role.User, Role.Accountant, Role.Admin))
)
{ }
public override bool Allows(Document value) => base.Records.Any(record => record.Value == value.DocumentTypeId.ToString() && record.Take);
}
}