User permissions for all tabs
This commit is contained in:
@@ -4,187 +4,29 @@
|
||||
using LaaProductionWeb.Services.Interfaces;
|
||||
using LaaProductionWeb.Services.Models;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public class AccountService : IAccountService
|
||||
{
|
||||
private readonly ISqlClient dbContext;
|
||||
private readonly ISqlClient sqlClient;
|
||||
|
||||
public AccountService(ISqlClient dbContext)
|
||||
=> this.dbContext = dbContext;
|
||||
public AccountService(ISqlClient sqlClient)
|
||||
=> this.sqlClient = sqlClient;
|
||||
|
||||
public WindowsUser GetOrCreateWindowsUser(string primarySID, string domainName, string userName)
|
||||
public Employee FindEmployee(string firstName, string lastName)
|
||||
{
|
||||
var user = this.dbContext.FirstOrDefault($@"
|
||||
DECLARE @userId INT;
|
||||
|
||||
SELECT @userId = [Account].[WindowsUsers].[UserId]
|
||||
FROM [Account].[WindowsUsers]
|
||||
WHERE [Account].[WindowsUsers].[PrimarySID] = @{nameof(primarySID)}
|
||||
|
||||
IF @userId IS NULL
|
||||
INSERT INTO [Account].[WindowsUsers] (
|
||||
[PrimarySID]
|
||||
, [DomainName]
|
||||
, [UserName])
|
||||
OUTPUT [Inserted].[UserId]
|
||||
VALUES (@{nameof(primarySID)}
|
||||
, @{nameof(domainName)}
|
||||
, @{nameof(userName)})
|
||||
ELSE SELECT @userId",
|
||||
var permissions = this.sqlClient.ExecuteReader($@"
|
||||
SELECT [MitarbeiterRechte].[Recht]
|
||||
FROM [Mitarbeiter]
|
||||
JOIN [MitarbeiterRechte]
|
||||
ON [MitarbeiterRechte].[MitarbeiterNr] = [Mitarbeiter].[MitarbeiterNr]
|
||||
WHERE [Vorname] LIKE @{nameof(firstName)}
|
||||
AND [Name] LIKE @{nameof(lastName)}
|
||||
AND [MitarbeiterRechte].[Recht] LIKE 'WEB_%'",
|
||||
parameters => parameters
|
||||
.Add(nameof(primarySID), primarySID)
|
||||
.Add(nameof(domainName), domainName)
|
||||
.Add(nameof(userName), userName),
|
||||
reader => new WindowsUser
|
||||
{
|
||||
UserId = reader.GetValue<int>(0)
|
||||
})
|
||||
?? new WindowsUser();
|
||||
|
||||
user.Roles = this
|
||||
.GetUserRoles(user.UserId)
|
||||
.Select(x => x.RoleName);
|
||||
.Add(nameof(firstName), firstName)
|
||||
.Add(nameof(lastName), lastName),
|
||||
reader => reader.GetString());
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
public PermissionsModel GetPermissionModelForUser(int userId, string role)
|
||||
{
|
||||
var roleModel = this.GetRoleForUser(role);
|
||||
|
||||
return new PermissionsModel
|
||||
{
|
||||
UserId = userId,
|
||||
Role = roleModel
|
||||
};
|
||||
}
|
||||
|
||||
public UserRole GetRoleForUser(string role)
|
||||
=> this.dbContext.FirstOrDefault($@"
|
||||
SELECT [Account].[Roles].[RoleId]
|
||||
, [Account].[Roles].[RoleName]
|
||||
, [Account].[Roles].[DisplayName]
|
||||
, [Account].[UsersRoles].[Approved]
|
||||
FROM [Account].[Roles]
|
||||
LEFT JOIN [Account].[UsersRoles]
|
||||
ON [Account].[UsersRoles].[RoleId] = [Account].[Roles].[RoleId]
|
||||
WHERE [Account].[Roles].[RoleName] = @{nameof(role)}",
|
||||
parameters => parameters.Add(nameof(role), role),
|
||||
reader => new UserRole
|
||||
{
|
||||
RoleId = reader.GetValue<int>(0),
|
||||
RoleName = reader.GetString(1),
|
||||
DisplayName = reader.GetString(2),
|
||||
Pending = reader.GetValue<bool?>(3),
|
||||
}) ?? new UserRole();
|
||||
|
||||
public IEnumerable<UserRole> GetUserRoles(int userId)
|
||||
=> this.dbContext.ExecuteReader($@"
|
||||
SELECT [Account].[Roles].[RoleId]
|
||||
, [Account].[Roles].[RoleName]
|
||||
, [Account].[Roles].[DisplayName]
|
||||
FROM [Account].[Roles]
|
||||
JOIN [Account].[UsersRoles]
|
||||
ON [Account].[UsersRoles].[RoleId] = [Account].[Roles].[RoleId]
|
||||
AND [Account].[UsersRoles].[UserId] = @{nameof(userId)}
|
||||
AND [Account].[UsersRoles].[Approved] = 1",
|
||||
parameters => parameters.Add(nameof(userId), userId),
|
||||
reader => new UserRole
|
||||
{
|
||||
RoleId = reader.GetValue<int>(0),
|
||||
RoleName = reader.GetString(1),
|
||||
DisplayName = reader.GetString(2),
|
||||
});
|
||||
|
||||
public List<UserPermissions> GetUsersWithPendingRoles()
|
||||
=> this.dbContext.ExecuteReader($@"
|
||||
SELECT [Account].[Users].[UserId]
|
||||
, [Account].[Users].[FirstName] + ' ' + [Account].[Users].[LastName]
|
||||
, [Account].[Roles].[RoleId]
|
||||
, [Account].[Roles].[RoleName]
|
||||
, [Account].[UsersRoles].[Approved]
|
||||
FROM [Account].[UsersRoles]
|
||||
JOIN [Account].[Roles] ON [Account].[Roles].[RoleId] = [Account].[UsersRoles].[RoleId]
|
||||
JOIN [Account].[Users] ON [Account].[Users].[UserId] = [Account].[UsersRoles].[UserId]
|
||||
WHERE [Account].[UsersRoles].[Approved] = 0",
|
||||
reader => new
|
||||
{
|
||||
UserId = reader.GetValue<int>(0),
|
||||
DisplayName = reader.GetString(1),
|
||||
RoleId = reader.GetValue<int>(2),
|
||||
RoleName = reader.GetString(3),
|
||||
Approved = reader.GetValue<bool>(4)
|
||||
})
|
||||
.GroupBy(x => new UserPermissions
|
||||
{
|
||||
UserId = x.UserId,
|
||||
DisplayName = x.DisplayName
|
||||
}, UserPermissionsComparer.Current)
|
||||
.Select(x => new UserPermissions
|
||||
{
|
||||
UserId = x.Key.UserId,
|
||||
DisplayName = x.Key.DisplayName,
|
||||
Roles = x
|
||||
.AsEnumerable()
|
||||
.Select(r => new RoleModel
|
||||
{
|
||||
RoleId = r.RoleId,
|
||||
RoleName = r.RoleName,
|
||||
Approved = r.Approved
|
||||
})
|
||||
.ToList()
|
||||
})
|
||||
.ToList();
|
||||
|
||||
public void RequestPermissions(PermissionsModel model)
|
||||
{
|
||||
this.dbContext.ExecuteNonQuery($@"
|
||||
INSERT INTO [Auftrag].[Account].[Users] (
|
||||
[UserId]
|
||||
, [FirstName]
|
||||
, [LastName])
|
||||
VALUES (@{nameof(model.UserId)}
|
||||
, @{nameof(model.FirstName)}
|
||||
, @{nameof(model.LastName)})",
|
||||
parameters => parameters
|
||||
.Add(nameof(model.UserId), model.UserId)
|
||||
.Add(nameof(model.FirstName), model.FirstName)
|
||||
.Add(nameof(model.LastName), model.LastName));
|
||||
|
||||
model.Role.Pending = this.dbContext.ExecuteNonQuery($@"
|
||||
INSERT INTO [Auftrag].[Account].[UsersRoles] (
|
||||
[UserId]
|
||||
, [RoleId])
|
||||
VALUES (@{nameof(model.UserId)}
|
||||
, @{nameof(model.Role.RoleId)})",
|
||||
parameters => parameters
|
||||
.Add(nameof(model.UserId), model.UserId)
|
||||
.Add(nameof(model.Role.RoleId), model.Role.RoleId)) == 1;
|
||||
}
|
||||
|
||||
public void SaveUserPermissions(IEnumerable<UserPermissions> usersPermissions)
|
||||
{
|
||||
foreach (var user in usersPermissions)
|
||||
{
|
||||
foreach (var role in user.Roles)
|
||||
{
|
||||
this.dbContext.ExecuteNonQuery(
|
||||
role.Deleted
|
||||
? $@"DELETE FROM [Account].[UsersRoles]
|
||||
WHERE [Account].[UsersRoles].[UserId] = @{nameof(user.UserId)}
|
||||
AND [Account].[UsersRoles].[RoleId] = @{nameof(role.RoleId)}"
|
||||
: $@"UPDATE [Account].[UsersRoles]
|
||||
SET [Approved] = @{nameof(role.Approved)}
|
||||
WHERE [Account].[UsersRoles].[UserId] = @{nameof(user.UserId)}
|
||||
AND [Account].[UsersRoles].[RoleId] = @{nameof(role.RoleId)}",
|
||||
parameters => parameters
|
||||
.Add(nameof(user.UserId), user.UserId)
|
||||
.Add(nameof(role.RoleId), role.RoleId)
|
||||
.Add(nameof(role.Approved), role.Approved));
|
||||
}
|
||||
}
|
||||
return new Employee(permissions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,22 +2,8 @@
|
||||
{
|
||||
using LaaProductionWeb.Services.Models;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
public interface IAccountService : ITransient
|
||||
{
|
||||
WindowsUser GetOrCreateWindowsUser(string primarySID, string domainName, string userName);
|
||||
|
||||
PermissionsModel GetPermissionModelForUser(int userId, string role);
|
||||
|
||||
IEnumerable<UserRole> GetUserRoles(int userId);
|
||||
|
||||
List<UserPermissions> GetUsersWithPendingRoles();
|
||||
|
||||
UserRole GetRoleForUser(string role);
|
||||
|
||||
void RequestPermissions(PermissionsModel model);
|
||||
|
||||
void SaveUserPermissions(IEnumerable<UserPermissions> usersPermissions);
|
||||
Employee FindEmployee(string firstName, string lastName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
<Compile Include="Interfaces\IReportService.cs" />
|
||||
<Compile Include="Interfaces\IShipmentsService.cs" />
|
||||
<Compile Include="Interfaces\ITransient.cs" />
|
||||
<Compile Include="Models\Employee.cs" />
|
||||
<Compile Include="Models\HeliumPressurePoint.cs" />
|
||||
<Compile Include="Models\HeliumReportFilter.cs" />
|
||||
<Compile Include="Models\HeliumReportFilterProperty.cs" />
|
||||
@@ -76,10 +77,6 @@
|
||||
<Compile Include="Models\PalletPosition.cs" />
|
||||
<Compile Include="Models\ProductionApproval.cs" />
|
||||
<Compile Include="Models\ProductionOrders.cs" />
|
||||
<Compile Include="Models\RoleModel.cs" />
|
||||
<Compile Include="Models\UserRole.cs" />
|
||||
<Compile Include="Models\UserPermissions.cs" />
|
||||
<Compile Include="Models\WindowsUser.cs" />
|
||||
<Compile Include="Models\BatchPrintModel.cs" />
|
||||
<Compile Include="Models\OrderClientModel.cs" />
|
||||
<Compile Include="Models\OrderInfoModel.cs" />
|
||||
@@ -88,7 +85,6 @@
|
||||
<Compile Include="Models\OrderScanModel.cs" />
|
||||
<Compile Include="Models\OrdersFoundModel.cs" />
|
||||
<Compile Include="Models\PalletsBatchModel.cs" />
|
||||
<Compile Include="Models\PermissionsModel.cs" />
|
||||
<Compile Include="Models\Result.cs" />
|
||||
<Compile Include="Models\SerialNr.cs" />
|
||||
<Compile Include="Models\ShipmentModel.cs" />
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace LaaProductionWeb.Services.Models
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class Employee
|
||||
{
|
||||
public Employee(IEnumerable<string> permissions)
|
||||
=> this.Permissions = permissions;
|
||||
|
||||
public IEnumerable<string> Permissions { get; }
|
||||
= Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
namespace LaaProductionWeb.Services.Models
|
||||
{
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
public class PermissionsModel
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
|
||||
[Display(Name = "Vorname")]
|
||||
[Required(ErrorMessage = "Die Vorname ist erforderlich.")]
|
||||
public string FirstName { get; set; }
|
||||
|
||||
[Display(Name = "Name")]
|
||||
[Required(ErrorMessage = "Die Name ist erforderlich.")]
|
||||
public string LastName { get; set; }
|
||||
|
||||
public UserRole Role { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace LaaProductionWeb.Services.Models
|
||||
{
|
||||
public class RoleModel
|
||||
{
|
||||
public int RoleId { get; set; }
|
||||
|
||||
public string RoleName { get; set; }
|
||||
|
||||
public bool Approved { get; set; }
|
||||
|
||||
public bool Deleted { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
namespace LaaProductionWeb.Services.Models
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class UserPermissions
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
public List<RoleModel> Roles { get; set; }
|
||||
}
|
||||
|
||||
public class UserPermissionsComparer : IEqualityComparer<UserPermissions>
|
||||
{
|
||||
public bool Equals(UserPermissions x, UserPermissions y)
|
||||
=> x?.UserId == y?.UserId;
|
||||
|
||||
public int GetHashCode(UserPermissions obj)
|
||||
=> obj?.UserId ?? default(int);
|
||||
|
||||
public static UserPermissionsComparer Current
|
||||
= new UserPermissionsComparer();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace LaaProductionWeb.Services.Models
|
||||
{
|
||||
public class UserRole
|
||||
{
|
||||
public int RoleId { get; set; }
|
||||
|
||||
public string RoleName { get; set; }
|
||||
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
public bool? Pending { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace LaaProductionWeb.Services.Models
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class WindowsUser
|
||||
{
|
||||
public int UserId { get; set; } = -1;
|
||||
|
||||
public IEnumerable<string> Roles { get; set; } = Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,14 @@
|
||||
|
||||
public class OrdersService : IOrdersService
|
||||
{
|
||||
private readonly ISqlClient dbContext;
|
||||
private readonly ISqlClient sqlClient;
|
||||
|
||||
public OrdersService(ISqlClient dbContext)
|
||||
=> this.dbContext = dbContext;
|
||||
public OrdersService(ISqlClient sqlClient)
|
||||
=> this.sqlClient = sqlClient;
|
||||
|
||||
public OrdersFoundModel FindOrders(string search)
|
||||
{
|
||||
var ordersFound = this.dbContext.ExecuteReader(
|
||||
var ordersFound = this.sqlClient.ExecuteReader(
|
||||
query: $@"
|
||||
SELECT DISTINCT
|
||||
[AlleAuftragPositionen].[AuftragNr] -- 0
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
public OrderPositions FindPositions(string orderNr)
|
||||
{
|
||||
var positionsFound = this.dbContext.ExecuteReader(
|
||||
var positionsFound = this.sqlClient.ExecuteReader(
|
||||
query: $@"
|
||||
SELECT DISTINCT
|
||||
[AlleAuftragPositionen].[PositionNr] -- 0
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
public ProductionOrders FindProductionOrders(string productionNr)
|
||||
{
|
||||
var ordersFound = this.dbContext.ExecuteReader($@"
|
||||
var ordersFound = this.sqlClient.ExecuteReader($@"
|
||||
SELECT DISTINCT
|
||||
[AlleAuftragPositionen].[FertigungsauftragNr] -- 1
|
||||
FROM [AlleAuftragPositionen]
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
|
||||
public class ProtocolService : IProtocolService
|
||||
{
|
||||
private readonly ISqlClient dbContext;
|
||||
private readonly ISqlClient sqlClient;
|
||||
|
||||
public ProtocolService(ISqlClient dbContext)
|
||||
=> this.dbContext = dbContext;
|
||||
public ProtocolService(ISqlClient sqlClient)
|
||||
=> this.sqlClient = sqlClient;
|
||||
|
||||
public bool DeleteFile(int fileId)
|
||||
=> this.dbContext.ExecuteScalar<int>($@"
|
||||
=> this.sqlClient.ExecuteScalar<int>($@"
|
||||
DELETE FROM [File]
|
||||
WHERE [FileId] = @{nameof(fileId)};
|
||||
DELETE FROM [FilesOrders]
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
public string FileContent(int? fileId)
|
||||
{
|
||||
var fileContent = this.dbContext.FirstOrDefault(
|
||||
var fileContent = this.sqlClient.FirstOrDefault(
|
||||
query: $@"
|
||||
SELECT [dbo].[File].[FileContent]
|
||||
FROM [dbo].[File]
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
public OrderClientModel FindOrder(int orderId)
|
||||
{
|
||||
var orderClientModel = this.dbContext.FirstOrDefault(
|
||||
var orderClientModel = this.sqlClient.FirstOrDefault(
|
||||
query: $@"
|
||||
SELECT DISTINCT
|
||||
[APG].[AuftragNr]
|
||||
@@ -72,7 +72,7 @@
|
||||
|
||||
if (orderClientModel != null && orderId > 0)
|
||||
{
|
||||
orderClientModel.FileId = this.dbContext.FirstOrDefault($@"
|
||||
orderClientModel.FileId = this.sqlClient.FirstOrDefault($@"
|
||||
SELECT [FileId]
|
||||
FROM [FilesOrders]
|
||||
WHERE [OrderId] = @{nameof(orderId)}
|
||||
@@ -85,7 +85,7 @@
|
||||
}
|
||||
|
||||
public IEnumerable<KeyValuePair<int, string>> FindOrdersById(int orderno)
|
||||
=> this.dbContext.ExecuteReader($@"
|
||||
=> this.sqlClient.ExecuteReader($@"
|
||||
SELECT DISTINCT
|
||||
[APG].[AuftragNr]
|
||||
, [K].[Name]
|
||||
@@ -104,7 +104,7 @@
|
||||
value: reader.GetString(1)));
|
||||
|
||||
public IEnumerable<KeyValuePair<int, string>> FindOrdersByClient(string clientName)
|
||||
=> this.dbContext.ExecuteReader(
|
||||
=> this.sqlClient.ExecuteReader(
|
||||
query: $@"
|
||||
SELECT DISTINCT
|
||||
[APG].[AuftragNr]
|
||||
@@ -124,7 +124,7 @@
|
||||
value: reader.GetString(1)));
|
||||
|
||||
public IEnumerable<TestStatus> LoadTestStatus(int orderId)
|
||||
=> this.dbContext.ExecuteReader(
|
||||
=> this.sqlClient.ExecuteReader(
|
||||
query: $@"
|
||||
SELECT DISTINCT
|
||||
[APS].[PositionNr] AS [PosNr] -- 0
|
||||
@@ -165,7 +165,7 @@
|
||||
|
||||
public bool OrderCompleted(int orderId)
|
||||
{
|
||||
var sumResults = this.dbContext.ExecuteReader($@"
|
||||
var sumResults = this.sqlClient.ExecuteReader($@"
|
||||
SELECT CAST(CASE WHEN ISNULL([CPT].[CordonelPressureTest_Valid], 1) = 1 THEN 0 ELSE 1 END AS INT)
|
||||
+ CAST(CASE WHEN ISNULL([DP].[Dicht], 1) = 1 THEN 0 ELSE 1 END AS INT)
|
||||
+ ISNULL(MAX([APS].[StatusFertigung]) - 30, 0)
|
||||
@@ -199,7 +199,7 @@
|
||||
var fileName = $"{clientId}_{orderId}.pdf";
|
||||
var fileContent = this.GetBuffer(fileStream);
|
||||
|
||||
return this.dbContext.ExecuteScalar<int>(
|
||||
return this.sqlClient.ExecuteScalar<int>(
|
||||
query: $@"
|
||||
INSERT INTO [dbo].[File] (
|
||||
[FileName]
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
|
||||
public class ReportService : IReportService
|
||||
{
|
||||
private readonly ISqlClient dbContext;
|
||||
private readonly ISqlClient sqlClient;
|
||||
|
||||
public ReportService(ISqlClient dbContext)
|
||||
=> this.dbContext = dbContext;
|
||||
public ReportService(ISqlClient sqlClient)
|
||||
=> this.sqlClient = sqlClient;
|
||||
|
||||
public HeliumReportModel LoadHeliumPressureReport(HeliumReportModel model = null)
|
||||
{
|
||||
@@ -25,7 +25,7 @@
|
||||
var where = model.Filter.Where();
|
||||
var orderBy = model.Filter.OrderBy();
|
||||
|
||||
model.Items = this.dbContext.ExecuteReader($@"
|
||||
model.Items = this.sqlClient.ExecuteReader($@"
|
||||
SELECT [PT].[CordonelPressureTest_FertigungsAuftragsNr] AS [FertigungNr] -- 0 Filter
|
||||
, [POS].[AuftragNr] AS [AuftragNr] -- 1 Filter
|
||||
, [POS].[PositionNr] AS [PositionNr] -- 2 Filter
|
||||
@@ -94,7 +94,7 @@
|
||||
}
|
||||
|
||||
public IEnumerable<HeliumPressurePoint> LoadHeliumPressureResults(int testId)
|
||||
=> this.dbContext.ExecuteReader($@"
|
||||
=> this.sqlClient.ExecuteReader($@"
|
||||
SELECT [CordonelPressureTestTestPoints_Id]
|
||||
, [CordonelPressureTest_TestPointNr]
|
||||
, CAST([CordonelPressureTest_TestPointResult] AS NUMERIC(9, 8))
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
|
||||
public class ShipmentsService : IShipmentsService
|
||||
{
|
||||
private readonly ISqlClient dbContext;
|
||||
private readonly ISqlClient sqlClient;
|
||||
|
||||
public ShipmentsService(ISqlClient dbContext)
|
||||
=> this.dbContext = dbContext;
|
||||
public ShipmentsService(ISqlClient sqlClient)
|
||||
=> this.sqlClient = sqlClient;
|
||||
|
||||
public OrderScanModel DeletePalletEntry(int id)
|
||||
{
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
public int GetPalletsCount(OrderScanModel model)
|
||||
{
|
||||
var palletsCount = this.dbContext.FirstOrDefault(
|
||||
var palletsCount = this.sqlClient.FirstOrDefault(
|
||||
query: $@"
|
||||
SELECT COUNT(1)
|
||||
FROM (SELECT [PalettenNr] AS [PalletNr]
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
public byte[] LoadBatchBuffer(OrderScanModel model)
|
||||
{
|
||||
var palletLoad = this.dbContext.ExecuteReader(
|
||||
var palletLoad = this.sqlClient.ExecuteReader(
|
||||
query: $@"
|
||||
SELECT [PalettenNr]
|
||||
, [SerienNr]
|
||||
@@ -76,7 +76,7 @@
|
||||
}
|
||||
|
||||
public IEnumerable<SerialNr> LoadBatchItems(OrderScanModel model)
|
||||
=> this.dbContext.ExecuteReader(
|
||||
=> this.sqlClient.ExecuteReader(
|
||||
query: $@"
|
||||
SELECT DISTINCT
|
||||
[PalettenScan].[ID] -- 0
|
||||
@@ -117,7 +117,7 @@
|
||||
const string orderNr = nameof(model.OrderNr);
|
||||
const string palNr = nameof(model.PalletNr);
|
||||
|
||||
var batchModel = this.dbContext.FirstOrDefault(
|
||||
var batchModel = this.sqlClient.FirstOrDefault(
|
||||
query: $@"
|
||||
SELECT TOP 1
|
||||
[Auftrag].[AuftragNr] -- 0
|
||||
@@ -156,7 +156,7 @@
|
||||
}
|
||||
|
||||
private IEnumerable<PalletPosition> LoadBatchPositions(OrderScanModel model, string orderNr, string palNr)
|
||||
=> this.dbContext.ExecuteReader($@"
|
||||
=> this.sqlClient.ExecuteReader($@"
|
||||
SELECT DISTINCT
|
||||
[Auftrag].[PositionNr]
|
||||
, COUNT(1)
|
||||
@@ -223,7 +223,7 @@
|
||||
}
|
||||
|
||||
private OrderScanModel DeletePalletEntryById(int id)
|
||||
=> this.dbContext.FirstOrDefault(
|
||||
=> this.sqlClient.FirstOrDefault(
|
||||
query: $@"
|
||||
DELETE
|
||||
FROM [PalettenScan]
|
||||
@@ -240,7 +240,7 @@
|
||||
});
|
||||
|
||||
private OrderIdentity UpdateOrderIdentifiers(int? orderNr, int? positionNr, string serialNr)
|
||||
=> this.dbContext.FirstOrDefault(
|
||||
=> this.sqlClient.FirstOrDefault(
|
||||
query: $@"
|
||||
SELECT DISTINCT TOP 1
|
||||
[AuftragPositionSerienNr].[PositionNr] -- 0
|
||||
@@ -263,7 +263,7 @@
|
||||
});
|
||||
|
||||
private int InsertPalletEntry(OrderScanModel model)
|
||||
=> this.dbContext.ExecuteNonQuery($@"
|
||||
=> this.sqlClient.ExecuteNonQuery($@"
|
||||
INSERT
|
||||
INTO [PalettenScan] (
|
||||
[PalettenNr]
|
||||
@@ -289,7 +289,7 @@
|
||||
.Add(nameof(model.Place), model.Place));
|
||||
|
||||
private bool PalletsEntryExists(int? orderNr, int? positionNr, string serialNr)
|
||||
=> this.dbContext.FirstOrDefault($@"
|
||||
=> this.sqlClient.FirstOrDefault($@"
|
||||
SELECT CAST(CASE WHEN [PalettenScan].[ID] IS NULL THEN 0 ELSE 1 END AS BIT)
|
||||
FROM [PalettenScan]
|
||||
WHERE [PalettenScan].[AuftragNr] = @{nameof(orderNr)}
|
||||
@@ -300,7 +300,7 @@
|
||||
reader => reader.GetValue<bool>(0));
|
||||
|
||||
private bool UpdatePalletsNr(OrderScanModel model)
|
||||
=> this.dbContext.FirstOrDefault($@"
|
||||
=> this.sqlClient.FirstOrDefault($@"
|
||||
BEGIN TRANSACTION
|
||||
------------------------------------------------------------------------
|
||||
DECLARE @rowsByAuftragPosition INT = (
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
{
|
||||
if (filterContext.HttpContext.User is ClaimsPrincipal claimsPrincipal)
|
||||
{
|
||||
filterContext.Result = new RedirectResult($"/Account/Authorize?role={this.Roles}");
|
||||
filterContext.Controller.TempData["Unauthorized"] = "Dir fehlen berechtigungen.";
|
||||
filterContext.Result = new RedirectResult($"/");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,48 +1,34 @@
|
||||
namespace LaaProductionWeb.App_Infrastructure
|
||||
{
|
||||
using LaaProductionWeb.Services.Interfaces;
|
||||
|
||||
using System;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.DirectoryServices.AccountManagement;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Principal;
|
||||
using System.Web.Mvc;
|
||||
|
||||
public class AuthorizationFilter : IAuthorizationFilter
|
||||
{
|
||||
public void OnAuthorization(AuthorizationContext filterContext)
|
||||
{
|
||||
if (filterContext.HttpContext.User is ClaimsPrincipal claimsPrincipal)
|
||||
if (filterContext.HttpContext.User is WindowsPrincipal windowsPrincipal)
|
||||
{
|
||||
this.GetWindowsUser(claimsPrincipal, out string primarySID, out string domainName, out string userName);
|
||||
|
||||
var accountService = ServiceProvider.Current.GetService<IAccountService>();
|
||||
var windowsUser = accountService.GetOrCreateWindowsUser(primarySID, domainName, userName);
|
||||
var claims = new List<Claim> { new Claim(ClaimTypes.NameIdentifier, $"{windowsUser.UserId}") };
|
||||
|
||||
foreach (var role in windowsUser.Roles)
|
||||
using (var principalContext = new PrincipalContext(ContextType.Domain))
|
||||
{
|
||||
claims.Add(new Claim(ClaimTypes.Role, role));
|
||||
var userPrincipal = UserPrincipal.FindByIdentity(principalContext, windowsPrincipal.Identity.Name);
|
||||
var accountService = ServiceProvider.Current.GetService<IAccountService>();
|
||||
var employee = accountService.FindEmployee(userPrincipal.GivenName, userPrincipal.Surname);
|
||||
var permissionsClaims = new List<Claim> { new Claim(ClaimTypes.Name, $"{userPrincipal.GivenName} {userPrincipal.Surname}") };
|
||||
|
||||
foreach (var permission in employee.Permissions)
|
||||
{
|
||||
permissionsClaims.Add(new Claim(ClaimTypes.Role, permission));
|
||||
}
|
||||
|
||||
windowsPrincipal.AddIdentity(new ClaimsIdentity(permissionsClaims, nameof(ClaimsPrincipal), ClaimTypes.Name, ClaimTypes.Role));
|
||||
}
|
||||
|
||||
var claimsIdentity = new ClaimsIdentity(claims, nameof(ClaimsPrincipal), ClaimTypes.Name, ClaimTypes.Role);
|
||||
|
||||
claimsPrincipal.AddIdentity(claimsIdentity);
|
||||
}
|
||||
}
|
||||
|
||||
private void GetWindowsUser(ClaimsPrincipal claimsPrincipal, out string primarySID, out string domainName, out string userName)
|
||||
{
|
||||
var nameTokens = claimsPrincipal
|
||||
.FindFirst(ClaimTypes.Name)
|
||||
?.Value
|
||||
?.ToLower()
|
||||
?.Split(new[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
?? Array.Empty<string>();
|
||||
|
||||
primarySID = claimsPrincipal.FindFirst(ClaimTypes.PrimarySid)?.Value;
|
||||
domainName = nameTokens.FirstOrDefault();
|
||||
userName = nameTokens.LastOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,24 +38,16 @@
|
||||
return serviceProvider;
|
||||
}
|
||||
|
||||
public static int NameIdentifier(this IPrincipal principal)
|
||||
public static string Name(this IPrincipal principal)
|
||||
{
|
||||
if (principal is ClaimsPrincipal claimsPrincipal)
|
||||
{
|
||||
var nameIdentifier = claimsPrincipal.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
if (int.TryParse($"{nameIdentifier}", out int userId))
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
return claimsPrincipal
|
||||
.FindAll(ClaimTypes.Name)
|
||||
.LastOrDefault()?.Value;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static T NameIdentifier<T>(this ViewContext viewContext)
|
||||
{
|
||||
return default(T);
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
public static string Display<T>(this T model, Expression<Func<T, object>> expression)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace LaaProductionWeb.App_Infrastructure
|
||||
{
|
||||
public class UserRoles
|
||||
{
|
||||
public const string WEB_Admin = nameof(WEB_Admin);
|
||||
public const string WEB_HeReport = nameof(WEB_HeReport);
|
||||
public const string WEB_PalettenScan = nameof(WEB_PalettenScan);
|
||||
public const string WEB_ProdApproval = nameof(WEB_ProdApproval);
|
||||
public const string WEB_PuneProtokoll = nameof(WEB_PuneProtokoll);
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
namespace LaaProductionWeb.Controllers
|
||||
{
|
||||
using LaaProductionWeb.App_Infrastructure;
|
||||
using LaaProductionWeb.Services.Interfaces;
|
||||
using LaaProductionWeb.Services.Models;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
|
||||
[Authorize]
|
||||
public class AccountController : Controller
|
||||
{
|
||||
private readonly IAccountService accountService;
|
||||
|
||||
public AccountController(IAccountService accountService)
|
||||
=> this.accountService = accountService;
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult Authorize(string role)
|
||||
{
|
||||
var userId = this.User.NameIdentifier();
|
||||
var permissionsModel = this.accountService
|
||||
.GetPermissionModelForUser(userId, role);
|
||||
|
||||
return this.View(model: permissionsModel);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Authorize(PermissionsModel model)
|
||||
{
|
||||
if (this.ModelState.IsValid)
|
||||
{
|
||||
this.accountService.RequestPermissions(model);
|
||||
}
|
||||
|
||||
return this.View(model);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[AllowedRoles("Admin")]
|
||||
public ActionResult Permissions()
|
||||
{
|
||||
var model = this.accountService.GetUsersWithPendingRoles();
|
||||
|
||||
return this.View(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[AllowedRoles("Admin")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Permissions(List<UserPermissions> model)
|
||||
{
|
||||
this.accountService.SaveUserPermissions(model);
|
||||
|
||||
model = this.accountService.GetUsersWithPendingRoles();
|
||||
|
||||
return this.View(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace LaaProductionWeb.Controllers
|
||||
{
|
||||
using LaaProductionWeb.App_Infrastructure;
|
||||
using LaaProductionWeb.Services.Interfaces;
|
||||
|
||||
using System.Web.Mvc;
|
||||
|
||||
[Authorize]
|
||||
[AllowedRoles(UserRoles.WEB_Admin)]
|
||||
public class AdminController : Controller
|
||||
{
|
||||
private readonly IAccountService accountService;
|
||||
|
||||
public AdminController(IAccountService accountService)
|
||||
=> this.accountService = accountService;
|
||||
|
||||
public ActionResult Index()
|
||||
=> this.View();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
namespace LaaProductionWeb.Controllers
|
||||
{
|
||||
using LaaProductionWeb.App_Infrastructure;
|
||||
using LaaProductionWeb.Services.Interfaces;
|
||||
using LaaProductionWeb.Services.Models;
|
||||
|
||||
@@ -7,6 +8,7 @@
|
||||
using System.Web.Mvc;
|
||||
|
||||
[Authorize]
|
||||
[AllowedRoles(UserRoles.WEB_ProdApproval)]
|
||||
public class ApprovalsController : Controller
|
||||
{
|
||||
private readonly IApprovalsService approvals;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
{
|
||||
using System.Web.Mvc;
|
||||
|
||||
[Authorize]
|
||||
public class HomeController : Controller
|
||||
{
|
||||
[HttpGet]
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
namespace LaaProductionWeb.Controllers
|
||||
{
|
||||
using LaaProductionWeb.App_Infrastructure;
|
||||
using LaaProductionWeb.Services.Interfaces;
|
||||
using LaaProductionWeb.Services.Models;
|
||||
|
||||
using System.Web.Mvc;
|
||||
|
||||
[Authorize]
|
||||
// [AllowedRoles("Protocol")]
|
||||
[AllowedRoles(UserRoles.WEB_PuneProtokoll)]
|
||||
public class ProtocolController : Controller
|
||||
{
|
||||
public const string FilePDF = nameof(FilePDF);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
namespace LaaProductionWeb.Controllers
|
||||
{
|
||||
using LaaProductionWeb.App_Infrastructure;
|
||||
using LaaProductionWeb.Services.Interfaces;
|
||||
using LaaProductionWeb.Services.Models;
|
||||
|
||||
using System.Web.Mvc;
|
||||
|
||||
[Authorize]
|
||||
// [AllowedRoles("HeReport")]
|
||||
[AllowedRoles(UserRoles.WEB_HeReport)]
|
||||
public class ReportController : Controller
|
||||
{
|
||||
private readonly IReportService reportService;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
namespace LaaProductionWeb.Controllers
|
||||
{
|
||||
using LaaProductionWeb.App_Infrastructure;
|
||||
using LaaProductionWeb.Services.Interfaces;
|
||||
using LaaProductionWeb.Services.Models;
|
||||
|
||||
@@ -13,7 +14,7 @@
|
||||
using SystemFile = System.IO.File;
|
||||
|
||||
[Authorize]
|
||||
// [AllowedRoles("Shipment")]
|
||||
[AllowedRoles(UserRoles.WEB_PalettenScan)]
|
||||
public class ShipmentsController : Controller
|
||||
{
|
||||
private readonly IShipmentsService shipmentsService;
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.DirectoryServices.AccountManagement" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http.Formatting, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.9\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||
@@ -72,6 +73,9 @@
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -137,12 +141,13 @@
|
||||
<Compile Include="App_Infrastructure\ExceptionFilter.cs" />
|
||||
<Compile Include="App_Infrastructure\AllowedRolesAttribute.cs" />
|
||||
<Compile Include="App_Infrastructure\ServiceProvider.cs" />
|
||||
<Compile Include="App_Infrastructure\UserRoles.cs" />
|
||||
<Compile Include="App_Start\BundleConfig.cs" />
|
||||
<Compile Include="App_Start\FilterConfig.cs" />
|
||||
<Compile Include="App_Start\RouteConfig.cs" />
|
||||
<Compile Include="App_Start\ServicesConfig.cs" />
|
||||
<Compile Include="App_Start\WebApiConfig.cs" />
|
||||
<Compile Include="Controllers\AccountController.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Controllers\ApprovalsController.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\ProtocolController.cs" />
|
||||
@@ -176,9 +181,6 @@
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<Content Include="Views\Shared\_PrintLayout.cshtml" />
|
||||
<Content Include="Views\Account\Authorize.cshtml" />
|
||||
<Content Include="Views\Account\UserRole.cshtml" />
|
||||
<Content Include="Views\Account\Permissions.cshtml" />
|
||||
<Content Include="Views\Report\Index.cshtml" />
|
||||
<Content Include="Views\Report\Filter.cshtml" />
|
||||
<Content Include="Views\Report\Results.cshtml" />
|
||||
@@ -186,6 +188,7 @@
|
||||
<None Include="Properties\PublishProfiles\FolderProfile.pubxml" />
|
||||
<Content Include="Views\Approvals\Add.cshtml" />
|
||||
<Content Include="Views\Search\Production.cshtml" />
|
||||
<Content Include="Views\Admin\Index.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="App_Content\font\fonts\bootstrap-icons.woff" />
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
@model PermissionsModel
|
||||
|
||||
@using LaaProductionWeb.Services.Models
|
||||
|
||||
<div class="d-flex justify-content-center align-items-center h-100">
|
||||
@if (this.Model.Role.Pending is null)
|
||||
{
|
||||
<div class="col-md-3 card p-5">
|
||||
<form action="/Account/Authorize" method="post" autocomplete="off">
|
||||
@this.Html.AntiForgeryToken()
|
||||
@this.Html.HiddenFor(x => x.UserId)
|
||||
@this.Html.Partial(nameof(UserRole), this.Model.Role, new ViewDataDictionary { { "namePattern", $"{nameof(this.Model.Role)}.{{0}}" } })
|
||||
<h5 class="mb-3">Ihnen fehlt die Berechtigung – '@this.Model.Role.DisplayName'.</h5>
|
||||
<div class="form-floating mb-3">
|
||||
@this.Html.TextBoxFor(x => x.FirstName, new { @class = "form-control", placeholder = "Vorname" })
|
||||
@this.Html.LabelFor(x => x.FirstName, new { @class = "text-secondary" })
|
||||
@this.Html.ValidationMessageFor(x => x.FirstName, string.Empty, new { @class = "small text-danger" })
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
@this.Html.TextBoxFor(x => x.LastName, new { @class = "form-control", placeholder = "Vorname" })
|
||||
@this.Html.LabelFor(x => x.LastName, new { @class = "text-secondary" })
|
||||
@this.Html.ValidationMessageFor(x => x.LastName, string.Empty, new { @class = "small text-danger" })
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary py-3 w-100">Berechtigung anfordern</button>
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="col-md-3 card p-5 border-success">
|
||||
<h1 class="text-center text-success"><i class="bi bi-shield-exclamation"></i></h1>
|
||||
<h6 class="text-center text-success">Ihre anfrage für die berechtigung – '@this.Model.Role.DisplayName' ist in bearbeitung ...</h6>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -1,60 +0,0 @@
|
||||
@model List<LaaProductionWeb.Services.Models.UserPermissions>
|
||||
|
||||
@if (this.Model.Any())
|
||||
{
|
||||
<form action="/Account/Permissions" method="post" autocomplete="off">
|
||||
@this.Html.AntiForgeryToken()
|
||||
<ul class="list-group list-group-flush mb-3">
|
||||
@{
|
||||
var usersCount = this.Model.Count;
|
||||
|
||||
for (int userIndex = 0; userIndex < usersCount; userIndex++)
|
||||
{
|
||||
var user = this.Model[userIndex];
|
||||
var hiddenUserId = $"[{userIndex}].{nameof(user.UserId)}";
|
||||
var hiddenUserName = $"[{userIndex}].{nameof(user.DisplayName)}";
|
||||
|
||||
<li class="list-group-item">
|
||||
<input type="hidden" name="@hiddenUserId" value="@user.UserId" />
|
||||
<input type="hidden" name="@hiddenUserName" value="@user.DisplayName" />
|
||||
<h5>@user.DisplayName</h5>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-secondary white-space-nowrap small px-3">Role Id</th>
|
||||
<th class="text-secondary white-space-nowrap small px-3">Role Name</th>
|
||||
<th class="text-secondary white-space-nowrap small px-3">Is Approved</th>
|
||||
<th class="text-secondary white-space-nowrap small px-3">Is Deleted</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@{
|
||||
var rolesCount = user.Roles.Count;
|
||||
|
||||
for (int roleIndex = 0; roleIndex < rolesCount; roleIndex++)
|
||||
{
|
||||
var role = user.Roles[roleIndex];
|
||||
var hiddenRoleId = $"[{userIndex}].{nameof(user.Roles)}[{roleIndex}].{nameof(role.RoleId)}";
|
||||
var hiddenRoleName = $"[{userIndex}].{nameof(user.Roles)}[{roleIndex}].{nameof(role.RoleName)}";
|
||||
var roleApproved = $"[{userIndex}].{nameof(user.Roles)}[{roleIndex}].{nameof(role.Approved)}";
|
||||
var roleDeleted = $"[{userIndex}].{nameof(user.Roles)}[{roleIndex}].{nameof(role.Deleted)}";
|
||||
|
||||
<tr>
|
||||
<td class="px-3">@role.RoleId <input type="hidden" name="@hiddenRoleId" value="@role.RoleId" /></td>
|
||||
<td class="px-3">@role.RoleName <input type="hidden" name="@hiddenRoleName" value="@role.RoleName" /></td>
|
||||
<td class="px-3">@this.Html.CheckBox(roleApproved, role.Approved, new { @class = "form-check-input" })</td>
|
||||
<td class="px-3">@this.Html.CheckBox(roleDeleted, role.Deleted, new { @class = "form-check-input" })</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
<button type="submit" class="btn btn-primary py-2 px-5 ms-3">Änderungen speichern</button>
|
||||
</form>
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
@model LaaProductionWeb.Services.Models.UserRole
|
||||
|
||||
@{
|
||||
var namePattern = "{0}";
|
||||
|
||||
if (this.ViewData.TryGetValue(nameof(namePattern), out object value))
|
||||
{
|
||||
namePattern = $"{value}";
|
||||
}
|
||||
}
|
||||
|
||||
@this.Html.Hidden(string.Format(namePattern, nameof(this.Model.RoleId)), this.Model.RoleId)
|
||||
@this.Html.Hidden(string.Format(namePattern, nameof(this.Model.RoleName)), this.Model.RoleName)
|
||||
@this.Html.Hidden(string.Format(namePattern, nameof(this.Model.DisplayName)), this.Model.DisplayName)
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<h2 class="mt-5">Hallo admin</h2>
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
@{
|
||||
var user = this.User
|
||||
?.Identity
|
||||
?.Name
|
||||
?.Split('\\')
|
||||
?.LastOrDefault()
|
||||
?.ToLower();
|
||||
}
|
||||
@using LaaProductionWeb.App_Infrastructure
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
@@ -29,23 +22,44 @@
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="mainnav">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-smallcaps" href="/Shipments">Paletten Scan</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-smallcaps" href="/Protocol">Prüfprotokoll</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-smallcaps" href="/Report">[He] Report</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-smallcaps" href="/Approvals/Add">Production Approval</a>
|
||||
</li>
|
||||
@if (this.User.IsInRole(UserRoles.WEB_PalettenScan))
|
||||
{
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-smallcaps" href="/Shipments">Paletten Scan</a>
|
||||
</li>
|
||||
}
|
||||
@if (this.User.IsInRole(UserRoles.WEB_PuneProtokoll))
|
||||
{
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-smallcaps" href="/Protocol">Prüfprotokoll</a>
|
||||
</li>
|
||||
}
|
||||
@if (this.User.IsInRole(UserRoles.WEB_HeReport))
|
||||
{
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-smallcaps" href="/Report">[He] Report</a>
|
||||
</li>
|
||||
}
|
||||
@if (this.User.IsInRole(UserRoles.WEB_ProdApproval))
|
||||
{
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-smallcaps" href="/Approvals/Add">Production Approval</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<span class="nav-link text-smallcaps">Benutzer: @user</span>
|
||||
</li>
|
||||
@if (this.User.IsInRole(UserRoles.WEB_Admin))
|
||||
{
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-smallcaps" href="/Admin">Admin: @this.User.Name()</a>
|
||||
</li>
|
||||
}
|
||||
else
|
||||
{
|
||||
<li class="nav-item">
|
||||
<span class="nav-link text-smallcaps">Benutzer: @this.User.Name()</span>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<add key="webpages:Enabled" value="false" />
|
||||
<add key="ClientValidationEnabled" value="true" />
|
||||
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
|
||||
<add key="ConnectionString" value="Data Source=SLASQL01.emea.sensus.net;Initial Catalog=Auftrag;Password=ServiceParingfile;Persist Security Info=True;User ID=ServiceParingfile;"/>
|
||||
<add key="ConnectionString" value="Data Source=SLASQL01.emea.sensus.net;Initial Catalog=Auftrag;Password=ServiceParingfile;Persist Security Info=True;User ID=ServiceParingfile;" />
|
||||
</appSettings>
|
||||
<system.web>
|
||||
<compilation debug="true" targetFramework="4.6.2" />
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="7.0.0" targetFramework="net462" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="2.0.0" targetFramework="net462" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net462" />
|
||||
<package id="System.DirectoryServices.AccountManagement" version="7.0.0" targetFramework="net462" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net462" />
|
||||
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net462" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net462" />
|
||||
<package id="WebGrease" version="1.6.0" targetFramework="net462" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user