From 50dcf3aff6358d2cc177e832c0e0bdf38b255ff7 Mon Sep 17 00:00:00 2001 From: ivanszabo Date: Tue, 15 Apr 2025 15:13:08 +0200 Subject: [PATCH] =?UTF-8?q?MobilUser=20lek=C3=A9rdez=C3=A9se?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/SyncController.cs | 44 ++++++++++++++++--- src/WorkFlowCheck.BL/Services/UserService.cs | 5 ++- src/WorkFlowCheck.Common/DTO/MobileUserDTO.cs | 1 - .../CheckListHeaderPage.cshtml | 2 +- 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/WorkFlowCheck.API/Controllers/SyncController.cs b/src/WorkFlowCheck.API/Controllers/SyncController.cs index 10edd21..1bc8bcb 100644 --- a/src/WorkFlowCheck.API/Controllers/SyncController.cs +++ b/src/WorkFlowCheck.API/Controllers/SyncController.cs @@ -16,15 +16,18 @@ namespace WorkFlowCheck.API.Controllers private ISyncService _syncService; private INumberGeneratorService _numberGeneratorService; private IMessageService _messageService; + private IUserService _userService; public SyncController(ISyncService syncService, INumberGeneratorService numberGeneratorService, + IUserService userService, IMessageService messageService) { _syncService = syncService; _numberGeneratorService = numberGeneratorService; _messageService = messageService; + _userService = userService; } @@ -35,13 +38,12 @@ namespace WorkFlowCheck.API.Controllers { IsSuccess = true, }; - var checkPointListDTO = await _syncService.GetCheckPointAsync(id); + var checkPointDTO = await _syncService.GetCheckPointAsync(id); - if (checkPointListDTO != null) + if (checkPointDTO != null) { - retVal.IsSuccess = true; - retVal.Data = checkPointListDTO; + retVal.Data = checkPointDTO; } else { @@ -508,9 +510,9 @@ namespace WorkFlowCheck.API.Controllers try { var result = await _messageService.SendMailAsync( - new List() - { - "ivan.szabo.sis@gmail.com", + new List() + { + "ivan.szabo.sis@gmail.com", }, "Teszt", "Ok"); retVal.Data = true; } @@ -522,5 +524,33 @@ namespace WorkFlowCheck.API.Controllers } return retVal; } + + + [HttpGet("GetAllMobileUsers")] + public async Task>> GetAllMobileUsers() + { + var retVal = new ApiResponseDTO>() + { + IsSuccess = true, + Data = new List() + }; + var usersListDTO = await _userService.GetAllUserAsync(); + + retVal.Data.AddRange(usersListDTO + .Where(user => user.RoleDTO.Any(role => role.CanUseMobilApp)) + .Select(user => new MobileUserDTO + { + Id = user.Id, + Email = user.Email, + FirstName = user.FirstName, + LastName = user.LastName, + NFCActive = user.NFCActive, + NFCCode = user.NFCCode, + UserName = user.UserName + }) + ); + if (retVal.Data == null || retVal.Data.Count <= 0) { retVal.IsSuccess = false; retVal.Errors.Add("No data!"); } + return retVal; + } } } diff --git a/src/WorkFlowCheck.BL/Services/UserService.cs b/src/WorkFlowCheck.BL/Services/UserService.cs index 3cd4a63..a96249d 100644 --- a/src/WorkFlowCheck.BL/Services/UserService.cs +++ b/src/WorkFlowCheck.BL/Services/UserService.cs @@ -68,7 +68,10 @@ namespace WorkFlowCheck.BL.Services }; try { - var users = await _dbContext.Users.ToListAsync(); + var users = await _dbContext.Users + .Include(i => i.UserRoles) + .ThenInclude(i => i.Role) + .ToListAsync(); if (users != null) { retVal = _mapper.Map>(users); diff --git a/src/WorkFlowCheck.Common/DTO/MobileUserDTO.cs b/src/WorkFlowCheck.Common/DTO/MobileUserDTO.cs index e6282de..8a31a43 100644 --- a/src/WorkFlowCheck.Common/DTO/MobileUserDTO.cs +++ b/src/WorkFlowCheck.Common/DTO/MobileUserDTO.cs @@ -13,7 +13,6 @@ namespace WorkFlowCheck.Common.DTO public string? FirstName { get; set; } public string? LastName { get; set; } public string? Email { get; set; } - public string? PhoneNumber { get; set; } public bool NFCActive { get; set; } public string NFCCode { get; set; } = null!; } diff --git a/src/WorkFlowCheck.Web/Pages/CheckList/CheckListHeader/CheckListHeaderPage.cshtml b/src/WorkFlowCheck.Web/Pages/CheckList/CheckListHeader/CheckListHeaderPage.cshtml index 08edf2f..4cb89d3 100644 --- a/src/WorkFlowCheck.Web/Pages/CheckList/CheckListHeader/CheckListHeaderPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/CheckList/CheckListHeader/CheckListHeaderPage.cshtml @@ -103,7 +103,7 @@ } ], - processing:true, + processing: true, language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',} });