From bd537d0d167952a8c82586405ea52cf87e7ca475 Mon Sep 17 00:00:00 2001 From: Stoyan Zlatev Date: Wed, 21 Jun 2023 16:55:34 +0200 Subject: [PATCH] software index --- .../Interfaces/ISoftwareManager.cs | 2 + .../LaaProduction.Personalization.csproj | 1 + .../Models/SoftwareItem.cs | 17 + .../Interfaces/ISoftwareRepository.cs | 4 + .../Repositories/SoftwareRepository.cs | 38 +- .../SoftwareManager.cs | 11 +- .../App_Content/css/styles.css | 4 + .../Controllers/SoftwareController.cs | 570 +++++++++--------- .../Models/Software/SoftwareListItem.cs | 17 + .../AddFunctionModel.cs | 0 .../EditFunctionModel.cs | 0 .../FunctionUsersInputModel.cs | 0 .../SoftwareEditModel.cs | 0 .../SoftwareFunctionModel.cs | 0 .../SoftwareFunctionsModel.cs | 0 .../{Software => _Software}/SoftwareModel.cs | 0 .../SoftwareOverviewModel.cs | 0 .../{Software => _Software}/SoftwareUser.cs | 0 .../SoftwareVersionModel.cs | 0 .../SoftwareVersionsModel.cs | 0 .../{Software => _Software}/UserFunctions.cs | 0 .../UsersFunctionsInputModel.cs | 0 .../UsersFunctionsModel.cs | 0 .../Views/EmployeesRoles/Index.cshtml | 121 ++-- .../Views/Shared/_SoftwareSidebar.cshtml | 6 - .../Views/Software/Index.cshtml | 45 +- .../API/Personalization/LoginController.cs | 1 + .../API/Personalization/SoftwareController.cs | 11 + .../LaaProduction.Web.csproj | 30 +- .../Views/Shared/_Layout.cshtml | 10 +- 30 files changed, 521 insertions(+), 367 deletions(-) create mode 100644 LaaProductionWeb/LaaProduction.Personalization/Models/SoftwareItem.cs create mode 100644 LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareListItem.cs rename LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/{Software => _Software}/AddFunctionModel.cs (100%) rename LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/{Software => _Software}/EditFunctionModel.cs (100%) rename LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/{Software => _Software}/FunctionUsersInputModel.cs (100%) rename LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/{Software => _Software}/SoftwareEditModel.cs (100%) rename LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/{Software => _Software}/SoftwareFunctionModel.cs (100%) rename LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/{Software => _Software}/SoftwareFunctionsModel.cs (100%) rename LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/{Software => _Software}/SoftwareModel.cs (100%) rename LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/{Software => _Software}/SoftwareOverviewModel.cs (100%) rename LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/{Software => _Software}/SoftwareUser.cs (100%) rename LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/{Software => _Software}/SoftwareVersionModel.cs (100%) rename LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/{Software => _Software}/SoftwareVersionsModel.cs (100%) rename LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/{Software => _Software}/UserFunctions.cs (100%) rename LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/{Software => _Software}/UsersFunctionsInputModel.cs (100%) rename LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/{Software => _Software}/UsersFunctionsModel.cs (100%) delete mode 100644 LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Views/Shared/_SoftwareSidebar.cshtml diff --git a/LaaProductionWeb/LaaProduction.Personalization/Interfaces/ISoftwareManager.cs b/LaaProductionWeb/LaaProduction.Personalization/Interfaces/ISoftwareManager.cs index c7855bb3..0846e7ff 100644 --- a/LaaProductionWeb/LaaProduction.Personalization/Interfaces/ISoftwareManager.cs +++ b/LaaProductionWeb/LaaProduction.Personalization/Interfaces/ISoftwareManager.cs @@ -7,5 +7,7 @@ IEnumerable GetFunctions(); IEnumerable GetFunctions(short appId); + + IEnumerable ListSoftwares(); } } diff --git a/LaaProductionWeb/LaaProduction.Personalization/LaaProduction.Personalization.csproj b/LaaProductionWeb/LaaProduction.Personalization/LaaProduction.Personalization.csproj index b17b84b6..214f8bb6 100644 --- a/LaaProductionWeb/LaaProduction.Personalization/LaaProduction.Personalization.csproj +++ b/LaaProductionWeb/LaaProduction.Personalization/LaaProduction.Personalization.csproj @@ -68,6 +68,7 @@ + diff --git a/LaaProductionWeb/LaaProduction.Personalization/Models/SoftwareItem.cs b/LaaProductionWeb/LaaProduction.Personalization/Models/SoftwareItem.cs new file mode 100644 index 00000000..51079885 --- /dev/null +++ b/LaaProductionWeb/LaaProduction.Personalization/Models/SoftwareItem.cs @@ -0,0 +1,17 @@ +namespace LaaProduction.Personalization.Models +{ + internal class SoftwareItem + { + public short SoftwareId { get; set; } + + public int VersionId { get; set; } + + public string AssemblyName { get; set; } + + public string CurrentVersion { get; set; } + + public string Description { get; set; } + + public string ValidUntil { get; set; } + } +} diff --git a/LaaProductionWeb/LaaProduction.Personalization/Repositories/Interfaces/ISoftwareRepository.cs b/LaaProductionWeb/LaaProduction.Personalization/Repositories/Interfaces/ISoftwareRepository.cs index f6ed0119..eb07be73 100644 --- a/LaaProductionWeb/LaaProduction.Personalization/Repositories/Interfaces/ISoftwareRepository.cs +++ b/LaaProductionWeb/LaaProduction.Personalization/Repositories/Interfaces/ISoftwareRepository.cs @@ -1,5 +1,7 @@ namespace LaaProduction.Personalization.Repositories.Interfaces { + using LaaProduction.Personalization.Models; + using System.Collections.Generic; internal interface ISoftwareRepository @@ -7,5 +9,7 @@ short AppId(string software); IEnumerable GetSoftwareFunctions(string token); + + IEnumerable List(); } } diff --git a/LaaProductionWeb/LaaProduction.Personalization/Repositories/SoftwareRepository.cs b/LaaProductionWeb/LaaProduction.Personalization/Repositories/SoftwareRepository.cs index f80bbe05..802f2c02 100644 --- a/LaaProductionWeb/LaaProduction.Personalization/Repositories/SoftwareRepository.cs +++ b/LaaProductionWeb/LaaProduction.Personalization/Repositories/SoftwareRepository.cs @@ -1,7 +1,7 @@ namespace LaaProduction.Personalization.Repositories { + using LaaProduction.Personalization.Models; using LaaProduction.Personalization.Repositories.Interfaces; - using LaaProductionSQL.Interfaces; using System.Collections.Generic; @@ -32,5 +32,41 @@ WHERE [MT].[Token] = @{nameof(token)}") .SetParameter(nameof(token), token) .ExecuteReader(x => x.GetString()); + + public IEnumerable List() + => this.sqlConnection + .CreateCommand($@" + SELECT [Software].[SoftwareId] + , [Software].[AssemblyName] + , [Software].[MajorV] + , [Software].[MinorV] + , [Software].[Build] + , [Software].[VersionId] + , [Software].[ValidUntil] + , [Software].[Description] + FROM (SELECT [AppID] AS [SoftwareId] + , [SoftwareAccess_Program] AS [AssemblyName] + , [SoftwareAccess_MajorVersion] AS [MajorV] + , [SoftwareAccess_MinorVersion] AS [MinorV] + , [SoftwareAccess_BuildVersion] AS [Build] + , [SoftwareAccess_ID] AS [VersionId] + , [SoftwareAccess_VaildTo] AS [ValidUntil] + , [SoftwareAccess_Desc] AS [Description] + , ROW_NUMBER() + OVER (PARTITION BY [AppID] + ORDER BY [SoftwareAccess_VaildTo] DESC) AS [RowNumber] + FROM [VersionSoftwareAccess]) + AS [Software] + WHERE [Software].[RowNumber] <= 1 + ORDER BY [Software].[AssemblyName]") + .ExecuteReader(x => new SoftwareItem + { + SoftwareId = x.GetSmallint(), + AssemblyName = x.GetString(), + CurrentVersion = $"{x.GetInt()}.{x.GetInt()}.{x.GetInt()}", + VersionId = x.GetInt(), + ValidUntil = $"{x.GetDate():yyyy-MM-dd}", + Description = x.GetString(), + }); } } diff --git a/LaaProductionWeb/LaaProduction.Personalization/SoftwareManager.cs b/LaaProductionWeb/LaaProduction.Personalization/SoftwareManager.cs index 8fc1ce2d..52b3c169 100644 --- a/LaaProductionWeb/LaaProduction.Personalization/SoftwareManager.cs +++ b/LaaProductionWeb/LaaProduction.Personalization/SoftwareManager.cs @@ -1,6 +1,7 @@ namespace LaaProduction.Personalization { using LaaProduction.Personalization.Interfaces; + using LaaProduction.Personalization.Models; using LaaProduction.Personalization.Repositories.Interfaces; using LaaProductionDI; @@ -10,9 +11,13 @@ public class SoftwareManager : ISoftwareManager { private readonly IFunctionsRepository functionsRepository; + private readonly ISoftwareRepository softwareRepository; public SoftwareManager() - => this.functionsRepository = LaaServiceProvider.GetService(); + { + this.functionsRepository = LaaServiceProvider.GetService(); + this.softwareRepository = LaaServiceProvider.GetService(); + } public IEnumerable GetFunctions() => this.functionsRepository.All() @@ -21,5 +26,9 @@ public IEnumerable GetFunctions(short appId) => this.functionsRepository.All(appId) ?? Array.Empty(); + + public IEnumerable ListSoftwares() + => this.softwareRepository.List() + ?? Array.Empty(); } } diff --git a/LaaProductionWeb/LaaProduction.Web/App_Content/css/styles.css b/LaaProductionWeb/LaaProduction.Web/App_Content/css/styles.css index 07a46480..ec2c9610 100644 --- a/LaaProductionWeb/LaaProduction.Web/App_Content/css/styles.css +++ b/LaaProductionWeb/LaaProduction.Web/App_Content/css/styles.css @@ -141,6 +141,10 @@ table.table table.table { text-decoration: underline !important; } +.hover-light:hover > * { + background-color: var(--bs-gray-200); +} + label.bi-search:before { position: relative !important; left: -.5rem !important; diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Controllers/SoftwareController.cs b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Controllers/SoftwareController.cs index 5aba3477..ab73f504 100644 --- a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Controllers/SoftwareController.cs +++ b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Controllers/SoftwareController.cs @@ -3,326 +3,348 @@ using LaaProduction.Personalization; using LaaProduction.Web.App_Infrastructure; using LaaProduction.Web.Areas.Personalization.Models.Software; - using LaaProduction.Services.Interfaces; using LaaProductionDI; + using LaaProductionHttp.Interfaces; using System; - using System.Linq; + using System.Collections.Generic; + using System.Threading.Tasks; using System.Web.Mvc; [RouteArea("Personalization")] [AllowedRoles(EmployeesRoles.WEB_Admin)] public class SoftwareController : Controller { - private readonly ISoftwareService softwareService; + private readonly IHttpClient localHttp; - public SoftwareController() - => this.softwareService = LaaServiceProvider.GetService(); - - [HttpGet] - public ActionResult Index() - { - var model = new SoftwareModel - { - SoftwareInfo = this.softwareService - .GetSoftwares() - .Select(x => new SoftwareOverviewModel - { - AppId = x.AppId, - Name = x.Name - .Split('.') - .LastOrDefault(), - Versions = x.Versions, - Functions = x.Functions - }) - }; - - return this.View(model); - } + public SoftwareController() + => this.localHttp = LaaServiceProvider.GetService(); [HttpGet] - public ActionResult SoftwareVersions(short? id) + public async Task Index() { - var model = new SoftwareVersionsModel(); + var softwareResult = await this.localHttp + .Get("/Personalization/Software/List") + .AuthorizeBearer(this.User.GetNameIdentifier()) + .SendAsync>(); - if (id.HasValue) + if (!softwareResult.Succeeded) { - var appId = id.Value; - - model = this.softwareService - .GetSoftwareOverview(appId) - .Map(x => new SoftwareVersionsModel - { - AppId = x.AppId, - Name = x.Name - .Split('.') - .LastOrDefault(), - Versions = x.Versions, - Functions = x.Functions - }); - - if (model != null) - { - model.SoftwareVersions = this.softwareService - .GetSoftwareVersions(appId) - .Select(x => new SoftwareVersionModel - { - AppId = x.AppId, - BuildV = x.BuildV, - Description = x.Description, - FullName = x.FullName, - Id = x.Id, - MajorV = x.MajorV, - MinorV = x.MinorV, - ValidTo = x.ValidTo - }); - } + this.ModelState.AddModelErrors(softwareResult); } - return this.View(model); + return this.View(softwareResult.Value ?? Array.Empty()); } - [HttpGet] - public ActionResult SoftwareFunctions(short? id) - { - var appId = id ?? 0; - var model = new SoftwareFunctionsModel(); + //private readonly ISoftwareService softwareService; - if (appId > 0) - { - model = this.softwareService - .GetSoftwareOverview(appId) - .Map(x => new SoftwareFunctionsModel - { - AppId = x.AppId, - Name = x.Name - .Split('.') - .LastOrDefault(), - Versions = x.Versions, - Functions = x.Functions - }) ?? model; + //public SoftwareController() + // => this.softwareService = LaaServiceProvider.GetService(); - model.SoftwareFunctions = this.softwareService - .GetSoftwareFunctions(appId) - .Select(x => new SoftwareFunctionModel - { - Id = x.Id, - AppId = x.AppId, - Function = x.Function - }); - } - else - { - model.SoftwareFunctions = this.softwareService - .GetAllSoftwareFunctions() - .Select(x => new SoftwareFunctionModel - { - Id = x.Id, - AppId = x.AppId, - Function = x.Function - }); - } + //[HttpGet] + //public ActionResult Index() + //{ + // var model = new SoftwareModel + // { + // SoftwareInfo = this.softwareService + // .GetSoftwares() + // .Select(x => new SoftwareOverviewModel + // { + // AppId = x.AppId, + // Name = x.Name + // .Split('.') + // .LastOrDefault(), + // Versions = x.Versions, + // Functions = x.Functions + // }) + // }; - model.Users = this.softwareService - .GetUsersWithFunctions() - .Select(x => new UserFunctions - { - Id = x.Id, - FirstName = x.FirstName, - LastName = x.LastName, - Username = x.Username, - FunctionsCount = x.FunctionsCount, - HasPassword = x.HasPassword, - Functions = x.Functions - ?.Split(new[] { '-' }, StringSplitOptions.RemoveEmptyEntries) - ?.Select(f => int.TryParse(f, out int funcId) ? funcId : 0) - ?.Where(f => f > 0) - ?? Array.Empty() - }); + // return this.View(model); + //} - return this.View(model); - } + //[HttpGet] + //public ActionResult SoftwareVersions(short? id) + //{ + // var model = new SoftwareVersionsModel(); - [HttpPost] - public ActionResult SoftwareFunctions(FunctionUsersInputModel model) - { - if (this.ModelState.IsValid) - { - this.softwareService.UpdateUsersFunctions(x => - { - x.FunctionId = model.FunctionId.Value; - x.Users = model.Users; - }); - } + // if (id.HasValue) + // { + // var appId = id.Value; - return this.Redirect(this.Request.UrlReferrer.ToString()); - } + // model = this.softwareService + // .GetSoftwareOverview(appId) + // .Map(x => new SoftwareVersionsModel + // { + // AppId = x.AppId, + // Name = x.Name + // .Split('.') + // .LastOrDefault(), + // Versions = x.Versions, + // Functions = x.Functions + // }); - [HttpGet] - public ActionResult SoftwareListGroup() - { - var softwareList = this.softwareService - .GetSoftwares() - .Select(x => new SoftwareOverviewModel - { - AppId = x.AppId, - Name = x.Name - .Split('.') - .LastOrDefault(), - Versions = x.Versions, - Functions = x.Functions - }); + // if (model != null) + // { + // model.SoftwareVersions = this.softwareService + // .GetSoftwareVersions(appId) + // .Select(x => new SoftwareVersionModel + // { + // AppId = x.AppId, + // BuildV = x.BuildV, + // Description = x.Description, + // FullName = x.FullName, + // Id = x.Id, + // MajorV = x.MajorV, + // MinorV = x.MinorV, + // ValidTo = x.ValidTo + // }); + // } + // } - return this.PartialView(softwareList); - } + // return this.View(model); + //} - [HttpPost] - public string AddFunction(AddFunctionModel model) - { - var appId = model.AppId.Value; + //[HttpGet] + //public ActionResult SoftwareFunctions(short? id) + //{ + // var appId = id ?? 0; + // var model = new SoftwareFunctionsModel(); - if (this.ModelState.IsValid) - { - this.softwareService.AddFunction(appId, model.Function); - } + // if (appId > 0) + // { + // model = this.softwareService + // .GetSoftwareOverview(appId) + // .Map(x => new SoftwareFunctionsModel + // { + // AppId = x.AppId, + // Name = x.Name + // .Split('.') + // .LastOrDefault(), + // Versions = x.Versions, + // Functions = x.Functions + // }) ?? model; - return this.ModelState - .SelectMany(x => x.Value.Errors.Select(e => e.ErrorMessage)) - .FirstOrDefault(x => !string.IsNullOrWhiteSpace(x)); - } + // model.SoftwareFunctions = this.softwareService + // .GetSoftwareFunctions(appId) + // .Select(x => new SoftwareFunctionModel + // { + // Id = x.Id, + // AppId = x.AppId, + // Function = x.Function + // }); + // } + // else + // { + // model.SoftwareFunctions = this.softwareService + // .GetAllSoftwareFunctions() + // .Select(x => new SoftwareFunctionModel + // { + // Id = x.Id, + // AppId = x.AppId, + // Function = x.Function + // }); + // } - [HttpPost] - public string EditFunction(EditFunctionModel model) - { - if (this.ModelState.IsValid) - { - if (string.IsNullOrWhiteSpace(model.Function)) - { - this.softwareService.DeleteFunction(model.FuncId.Value); - } - else - { - this.softwareService.UpdateFunction(model.FuncId.Value, model.Function); - } - } + // model.Users = this.softwareService + // .GetUsersWithFunctions() + // .Select(x => new UserFunctions + // { + // Id = x.Id, + // FirstName = x.FirstName, + // LastName = x.LastName, + // Username = x.Username, + // FunctionsCount = x.FunctionsCount, + // HasPassword = x.HasPassword, + // Functions = x.Functions + // ?.Split(new[] { '-' }, StringSplitOptions.RemoveEmptyEntries) + // ?.Select(f => int.TryParse(f, out int funcId) ? funcId : 0) + // ?.Where(f => f > 0) + // ?? Array.Empty() + // }); - return this.ModelState - .SelectMany(x => x.Value.Errors.Select(e => e.ErrorMessage)) - .FirstOrDefault(x => !string.IsNullOrWhiteSpace(x)); - } + // return this.View(model); + //} - [HttpGet] - public ActionResult Users() - { - var usersModel = this.softwareService - .GetUsers() - .Select(x => new SoftwareUser - { - Id = x.Id, - FirstName = x.FirstName, - LastName = x.LastName, - Username = x.Username, - FunctionsCount = x.FunctionsCount, - HasPassword = x.HasPassword - }); + //[HttpPost] + //public ActionResult SoftwareFunctions(FunctionUsersInputModel model) + //{ + // if (this.ModelState.IsValid) + // { + // this.softwareService.UpdateUsersFunctions(x => + // { + // x.FunctionId = model.FunctionId.Value; + // x.Users = model.Users; + // }); + // } - return this.View(usersModel); - } + // return this.Redirect(this.Request.UrlReferrer.ToString()); + //} - [HttpPost] - public ActionResult Users(string username) - { - var usersModel = this.softwareService - .GetUsers(username) - .Select(x => new SoftwareUser - { - Id = x.Id, - FirstName = x.FirstName, - LastName = x.LastName, - Username = x.Username, - FunctionsCount = x.FunctionsCount, - HasPassword = x.HasPassword - }); + //[HttpGet] + //public ActionResult SoftwareListGroup() + //{ + // var softwareList = this.softwareService + // .GetSoftwares() + // .Select(x => new SoftwareOverviewModel + // { + // AppId = x.AppId, + // Name = x.Name + // .Split('.') + // .LastOrDefault(), + // Versions = x.Versions, + // Functions = x.Functions + // }); - return this.View(usersModel); - } + // return this.PartialView(softwareList); + //} - [HttpGet] - public ActionResult UpdatePWDS() - { - this.softwareService.UpdatePasswordHashes(); + //[HttpPost] + //public string AddFunction(AddFunctionModel model) + //{ + // var appId = model.AppId.Value; - return this.RedirectToAction(nameof(Users)); - } + // if (this.ModelState.IsValid) + // { + // this.softwareService.AddFunction(appId, model.Function); + // } - [HttpPost] - public bool ResetPWD(short id) - { - this.softwareService.ResetPassword(id); + // return this.ModelState + // .SelectMany(x => x.Value.Errors.Select(e => e.ErrorMessage)) + // .FirstOrDefault(x => !string.IsNullOrWhiteSpace(x)); + //} - return true; - } + //[HttpPost] + //public string EditFunction(EditFunctionModel model) + //{ + // if (this.ModelState.IsValid) + // { + // if (string.IsNullOrWhiteSpace(model.Function)) + // { + // this.softwareService.DeleteFunction(model.FuncId.Value); + // } + // else + // { + // this.softwareService.UpdateFunction(model.FuncId.Value, model.Function); + // } + // } - [HttpGet] - public ActionResult UsersFunctions(int? id, string username) - { - object model; + // return this.ModelState + // .SelectMany(x => x.Value.Errors.Select(e => e.ErrorMessage)) + // .FirstOrDefault(x => !string.IsNullOrWhiteSpace(x)); + //} - if (id > 0) - { - model = this.UsersFunctionsModel(id: id.Value, username: $"{id}"); - } - else - { - model = this.UsersFunctionsModel(username: username); - } + //[HttpGet] + //public ActionResult Users() + //{ + // var usersModel = this.softwareService + // .GetUsers() + // .Select(x => new SoftwareUser + // { + // Id = x.Id, + // FirstName = x.FirstName, + // LastName = x.LastName, + // Username = x.Username, + // FunctionsCount = x.FunctionsCount, + // HasPassword = x.HasPassword + // }); - return this.View(model); - } + // return this.View(usersModel); + //} - [HttpPost] - public ActionResult UsersFunctions(UsersFunctionsInputModel model) - { - if (this.ModelState.IsValid) - { - this.softwareService.UpdateUsersFunctions(x => - { - x.UserId = model.UserId.Value; - x.Functions = model.Functions; - }); - } + //[HttpPost] + //public ActionResult Users(string username) + //{ + // var usersModel = this.softwareService + // .GetUsers(username) + // .Select(x => new SoftwareUser + // { + // Id = x.Id, + // FirstName = x.FirstName, + // LastName = x.LastName, + // Username = x.Username, + // FunctionsCount = x.FunctionsCount, + // HasPassword = x.HasPassword + // }); - return this.Redirect(this.Request.UrlReferrer.ToString()); - } + // return this.View(usersModel); + //} - private UsersFunctionsModel UsersFunctionsModel(int id = -1, string username = null) - => new UsersFunctionsModel - { - Functions = this.softwareService - .GetAllSoftwareFunctions() - .Select(x => new SoftwareFunctionModel - { - AppId = x.AppId, - Function = x.Function, - Id = x.Id, - }), - UsersFunctions = this.softwareService - .GetUsersWithFunctions(id, username) - .Select(x => new UserFunctions - { - Id = x.Id, - FirstName = x.FirstName, - LastName = x.LastName, - Username = x.Username, - FunctionsCount = x.FunctionsCount, - HasPassword = x.HasPassword, - Functions = x.Functions - ?.Split(new[] { '-' }, StringSplitOptions.RemoveEmptyEntries) - ?.Select(f => int.TryParse(f, out int funcId) ? funcId : 0) - ?.Where(f => f > 0) - ?? Array.Empty() - }) + //[HttpGet] + //public ActionResult UpdatePWDS() + //{ + // this.softwareService.UpdatePasswordHashes(); - }; + // return this.RedirectToAction(nameof(Users)); + //} + + //[HttpPost] + //public bool ResetPWD(short id) + //{ + // this.softwareService.ResetPassword(id); + + // return true; + //} + + //[HttpGet] + //public ActionResult UsersFunctions(int? id, string username) + //{ + // object model; + + // if (id > 0) + // { + // model = this.UsersFunctionsModel(id: id.Value, username: $"{id}"); + // } + // else + // { + // model = this.UsersFunctionsModel(username: username); + // } + + // return this.View(model); + //} + + //[HttpPost] + //public ActionResult UsersFunctions(UsersFunctionsInputModel model) + //{ + // if (this.ModelState.IsValid) + // { + // this.softwareService.UpdateUsersFunctions(x => + // { + // x.UserId = model.UserId.Value; + // x.Functions = model.Functions; + // }); + // } + + // return this.Redirect(this.Request.UrlReferrer.ToString()); + //} + + //private UsersFunctionsModel UsersFunctionsModel(int id = -1, string username = null) + // => new UsersFunctionsModel + // { + // Functions = this.softwareService + // .GetAllSoftwareFunctions() + // .Select(x => new SoftwareFunctionModel + // { + // AppId = x.AppId, + // Function = x.Function, + // Id = x.Id, + // }), + // UsersFunctions = this.softwareService + // .GetUsersWithFunctions(id, username) + // .Select(x => new UserFunctions + // { + // Id = x.Id, + // FirstName = x.FirstName, + // LastName = x.LastName, + // Username = x.Username, + // FunctionsCount = x.FunctionsCount, + // HasPassword = x.HasPassword, + // Functions = x.Functions + // ?.Split(new[] { '-' }, StringSplitOptions.RemoveEmptyEntries) + // ?.Select(f => int.TryParse(f, out int funcId) ? funcId : 0) + // ?.Where(f => f > 0) + // ?? Array.Empty() + // }) + + // }; } } \ No newline at end of file diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareListItem.cs b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareListItem.cs new file mode 100644 index 00000000..e868e534 --- /dev/null +++ b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareListItem.cs @@ -0,0 +1,17 @@ +namespace LaaProduction.Web.Areas.Personalization.Models.Software +{ + public class SoftwareListItem + { + public short SoftwareId { get; set; } + + public int VersionId { get; set; } + + public string AssemblyName { get; set; } + + public string CurrentVersion { get; set; } + + public string Description { get; set; } + + public string ValidUntil { get; set; } + } +} \ No newline at end of file diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/AddFunctionModel.cs b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/AddFunctionModel.cs similarity index 100% rename from LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/AddFunctionModel.cs rename to LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/AddFunctionModel.cs diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/EditFunctionModel.cs b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/EditFunctionModel.cs similarity index 100% rename from LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/EditFunctionModel.cs rename to LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/EditFunctionModel.cs diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/FunctionUsersInputModel.cs b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/FunctionUsersInputModel.cs similarity index 100% rename from LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/FunctionUsersInputModel.cs rename to LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/FunctionUsersInputModel.cs diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareEditModel.cs b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/SoftwareEditModel.cs similarity index 100% rename from LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareEditModel.cs rename to LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/SoftwareEditModel.cs diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareFunctionModel.cs b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/SoftwareFunctionModel.cs similarity index 100% rename from LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareFunctionModel.cs rename to LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/SoftwareFunctionModel.cs diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareFunctionsModel.cs b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/SoftwareFunctionsModel.cs similarity index 100% rename from LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareFunctionsModel.cs rename to LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/SoftwareFunctionsModel.cs diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareModel.cs b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/SoftwareModel.cs similarity index 100% rename from LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareModel.cs rename to LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/SoftwareModel.cs diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareOverviewModel.cs b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/SoftwareOverviewModel.cs similarity index 100% rename from LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareOverviewModel.cs rename to LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/SoftwareOverviewModel.cs diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareUser.cs b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/SoftwareUser.cs similarity index 100% rename from LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareUser.cs rename to LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/SoftwareUser.cs diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareVersionModel.cs b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/SoftwareVersionModel.cs similarity index 100% rename from LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareVersionModel.cs rename to LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/SoftwareVersionModel.cs diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareVersionsModel.cs b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/SoftwareVersionsModel.cs similarity index 100% rename from LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/SoftwareVersionsModel.cs rename to LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/SoftwareVersionsModel.cs diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/UserFunctions.cs b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/UserFunctions.cs similarity index 100% rename from LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/UserFunctions.cs rename to LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/UserFunctions.cs diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/UsersFunctionsInputModel.cs b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/UsersFunctionsInputModel.cs similarity index 100% rename from LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/UsersFunctionsInputModel.cs rename to LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/UsersFunctionsInputModel.cs diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/UsersFunctionsModel.cs b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/UsersFunctionsModel.cs similarity index 100% rename from LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/Software/UsersFunctionsModel.cs rename to LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Models/_Software/UsersFunctionsModel.cs diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Views/EmployeesRoles/Index.cshtml b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Views/EmployeesRoles/Index.cshtml index 5785c45d..d64daa8d 100644 --- a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Views/EmployeesRoles/Index.cshtml +++ b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Views/EmployeesRoles/Index.cshtml @@ -9,42 +9,79 @@ @this.Html.ValidationSummary() -

+

Beachten Sie, dass die Rechte nur in der Mitarbeiterrechtetabelle gespeichert werden. Wird ein Recht für alle Mitarbeiter gelöscht, verschwindet es aus der Liste.

-
- - +
+ + + + + + + + + + + + @{ + var roleCounter = 1; + } + @foreach (var role in this.Model.Roles) + { + var formId = $"form_{roleCounter++}"; + - - - - - - - + - @{ - var roleCounter = 1; - } - @foreach (var role in this.Model.Roles) - { - var formId = $"form_{roleCounter++}"; - - - - - - } - -
RechtMitarbaiter
+ + + +
RechtMitarbaiter
- - @role.Name
@role.Name - -
-
+ } + +
diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Views/Shared/_SoftwareSidebar.cshtml b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Views/Shared/_SoftwareSidebar.cshtml deleted file mode 100644 index 71ece3e2..00000000 --- a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Views/Shared/_SoftwareSidebar.cshtml +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Views/Software/Index.cshtml b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Views/Software/Index.cshtml index 2c6b502c..a768f0f9 100644 --- a/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Views/Software/Index.cshtml +++ b/LaaProductionWeb/LaaProduction.Web/Areas/Personalization/Views/Software/Index.cshtml @@ -1,6 +1,45 @@ -@model LaaProduction.Web.Areas.Personalization.Models.Software.SoftwareModel +@model IEnumerable -
+
+
+
+

Software

+
+
+ @this.Html.ValidationSummary() +
+
+
+
+ + + + + + + + + + + + @foreach (var software in this.Model) + { + + + + + + + + } + +
Software IdSoftwarenameAktuelle VersionGültig bisBeschreibung
@software.SoftwareId@software.AssemblyName@software.CurrentVersion@software.ValidUntil@software.Description
+
+
+
+
+ +@*
@@ -37,4 +76,4 @@ }
-
\ No newline at end of file +
*@ \ No newline at end of file diff --git a/LaaProductionWeb/LaaProduction.Web/Controllers/API/Personalization/LoginController.cs b/LaaProductionWeb/LaaProduction.Web/Controllers/API/Personalization/LoginController.cs index 83d8294a..840b32fb 100644 --- a/LaaProductionWeb/LaaProduction.Web/Controllers/API/Personalization/LoginController.cs +++ b/LaaProductionWeb/LaaProduction.Web/Controllers/API/Personalization/LoginController.cs @@ -6,6 +6,7 @@ using System.ComponentModel.DataAnnotations; using System.Web.Http; + [RoutePrefix("api/Personalization/Login")] public class LoginController : ApiController { private readonly IAccountManager accountManagement; diff --git a/LaaProductionWeb/LaaProduction.Web/Controllers/API/Personalization/SoftwareController.cs b/LaaProductionWeb/LaaProduction.Web/Controllers/API/Personalization/SoftwareController.cs index 74de4b56..325503be 100644 --- a/LaaProductionWeb/LaaProduction.Web/Controllers/API/Personalization/SoftwareController.cs +++ b/LaaProductionWeb/LaaProduction.Web/Controllers/API/Personalization/SoftwareController.cs @@ -7,6 +7,7 @@ using System.Web.Http; [AuthorizeBearer] + [RoutePrefix("api/Personalization/Software")] public class SoftwareController : ApiController { private readonly ISoftwareManager softwareManager; @@ -15,11 +16,21 @@ => this.softwareManager = LaaServiceProvider.GetService(); [HttpGet] + [Route(nameof(Functions))] public IHttpActionResult Functions() { var employeeRoles = this.softwareManager.GetFunctions(); return this.Json(employeeRoles); } + + [HttpGet] + [Route(nameof(List))] + public IHttpActionResult List() + { + var softwares = this.softwareManager.ListSoftwares(); + + return this.Json(softwares); + } } } diff --git a/LaaProductionWeb/LaaProduction.Web/LaaProduction.Web.csproj b/LaaProductionWeb/LaaProduction.Web/LaaProduction.Web.csproj index 938e12a9..d699bec7 100644 --- a/LaaProductionWeb/LaaProduction.Web/LaaProduction.Web.csproj +++ b/LaaProductionWeb/LaaProduction.Web/LaaProduction.Web.csproj @@ -165,20 +165,21 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -235,7 +236,6 @@ - diff --git a/LaaProductionWeb/LaaProduction.Web/Views/Shared/_Layout.cshtml b/LaaProductionWeb/LaaProduction.Web/Views/Shared/_Layout.cshtml index 0d132ce0..14ed66f1 100644 --- a/LaaProductionWeb/LaaProduction.Web/Views/Shared/_Layout.cshtml +++ b/LaaProductionWeb/LaaProduction.Web/Views/Shared/_Layout.cshtml @@ -27,19 +27,19 @@