-
Notifications
You must be signed in to change notification settings - Fork 0
/
AuthAttributes.cs
42 lines (35 loc) · 1.65 KB
/
AuthAttributes.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
namespace pwr_msi {
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
internal class AdminAuthorizeAttribute : Attribute {
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
internal class RestaurantAuthorizeAttribute : Attribute {
public RestaurantPermission Permission { get; }
public string RouteArgument { get; }
public RestaurantAuthorizeAttribute(RestaurantPermission permission, string routeArgument = "restaurantId") {
Permission = permission;
RouteArgument = routeArgument;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
internal class ManageRestaurantAuthorizeAttribute : RestaurantAuthorizeAttribute {
public ManageRestaurantAuthorizeAttribute(string routeArgument = "restaurantId") : base(RestaurantPermission.MANAGE, routeArgument) {
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
internal class AcceptOrdersRestaurantAuthorizeAttribute : RestaurantAuthorizeAttribute {
public AcceptOrdersRestaurantAuthorizeAttribute(string routeArgument = "restaurantId") : base(RestaurantPermission.ACCEPT, routeArgument) {
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
internal class DeliverFromRestaurantAuthorizeAttribute : RestaurantAuthorizeAttribute {
public DeliverFromRestaurantAuthorizeAttribute(string routeArgument = "restaurantId") : base(RestaurantPermission.DELIVER, routeArgument) {
}
}
internal enum RestaurantPermission {
MANAGE,
ACCEPT,
DELIVER,
};
}