ScientificReport
PageHelpers.cs
Go to the documentation of this file.
1 using System.Security.Claims;
4 
5 namespace ScientificReport.Controllers.Utils
6 {
7  public static class PageHelpers
8  {
9  public static bool IsAdmin(ClaimsPrincipal user)
10  {
11  return user.IsInRole(UserProfileRole.Administrator);
12  }
13 
14  public static bool IsHeadOfDepartment(ClaimsPrincipal user)
15  {
16  return user.IsInRole(UserProfileRole.HeadOfDepartment);
17  }
18 
19  public static bool IsAdminOrHead(ClaimsPrincipal user)
20  {
21  return IsAdmin(user) || IsHeadOfDepartment(user);
22  }
23 
24  public static bool IsTeacher(ClaimsPrincipal user)
25  {
26  return user.IsInRole(UserProfileRole.Teacher);
27  }
28 
29  public static string GetPublicationController(PublicationBase publication)
30  {
31  var result = "";
32  var publicationType = publication.GetType();
33  if (publicationType == typeof(Publication))
34  {
35  result = "Publication";
36  }
37  else if (publicationType == typeof(Article))
38  {
39  result = "Article";
40  }
41  else if (publicationType == typeof(ScientificWork))
42  {
43  result = "ScientificWork";
44  }
45 
46  return result;
47  }
48  }
49 }