diff --git a/CPRNIMS.Domain/Services/Finance/RR.cs b/CPRNIMS.Domain/Services/Finance/RR.cs index 39aeba5..b93b555 100644 --- a/CPRNIMS.Domain/Services/Finance/RR.cs +++ b/CPRNIMS.Domain/Services/Finance/RR.cs @@ -39,22 +39,14 @@ namespace CPRNIMS.Domain.Services.Finance } public async Task> GetRRDetailByPO(RRDetailsDto itemDto) { - try - { - var allItems = await _dbContext.ReceivingDetails - .FromSqlRaw($"EXEC GetRRDetailByPO @PONo,@POTypeId,@UserId", - new SqlParameter("@PONo", itemDto.PONo), - new SqlParameter("@POTypeId", itemDto.POTypeId), - new SqlParameter("@UserId", itemDto.UserId)) - .ToListAsync(); + var allItems = await _dbContext.ReceivingDetails + .FromSqlRaw($"EXEC GetRRDetailByPOFinance @PONo,@POTypeId,@UserId", + new SqlParameter("@PONo", itemDto.PONo), + new SqlParameter("@POTypeId", itemDto.POTypeId), + new SqlParameter("@UserId", itemDto.UserId)) + .ToListAsync(); - return allItems ?? new List(); - } - catch (SqlException ex) - { - ex.ToString(); - throw; - } + return allItems ?? new List(); } public async Task PostPutPayment(RRDetailsDto itemDto) diff --git a/CPRNIMS.Domain/UIContracts/Account/IAccount.cs b/CPRNIMS.Domain/UIContracts/Account/IAccount.cs index 6b9c6d9..6dc8233 100644 --- a/CPRNIMS.Domain/UIContracts/Account/IAccount.cs +++ b/CPRNIMS.Domain/UIContracts/Account/IAccount.cs @@ -18,6 +18,7 @@ namespace CPRNIMS.Domain.UIContracts.Account Task> GetAllUserAsync(User user); Task> GetAllRoleAsync(User user); Task> GetLandingPageByUserId(User user); + Task> GetLandingPageByUserId(User user,string token); Task> GetRoles(User user); Task> GetUserProfileById(User user); Task GetUserByEmail(string email, EmailMessageDetailsVM forgotPassword); diff --git a/CPRNIMS.Domain/UIServices/Account/Account.cs b/CPRNIMS.Domain/UIServices/Account/Account.cs index d56cc67..8784f3c 100644 --- a/CPRNIMS.Domain/UIServices/Account/Account.cs +++ b/CPRNIMS.Domain/UIServices/Account/Account.cs @@ -439,42 +439,31 @@ namespace CPRNIMS.Domain.UIServices.Account // Handle token retrieval failure return null; } - public async Task> GetLandingPageByUserId(User user) + public async Task> GetLandingPageByUserId(User user, string token) { try { - var token = await _tokenHelper.GetValidTokenAsync(); + if (string.IsNullOrEmpty(token)) + return null; - if (!string.IsNullOrEmpty(token)) + var jsonContent = JsonSerializer.Serialize(user); + var content = new StringContent(jsonContent, Encoding.UTF8, "application/json"); + + using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token)) { - var jsonContent = JsonSerializer.Serialize(user); - - var content = new StringContent(jsonContent, Encoding.UTF8, "application/json"); - - using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token)) + var response = await httpClient.PostAsync(_configuration["Account:GetLandingPageByUserId"], content); + if (response.IsSuccessStatusCode) { - var response = await httpClient.PostAsync(_configuration["Account:GetLandingPageByUserId"], content); - - if (response.IsSuccessStatusCode) + var jsonResponse = await response.Content.ReadAsStringAsync(); + var options = new JsonSerializerOptions { - var jsonResponse = await response.Content.ReadAsStringAsync(); - - var options = new JsonSerializerOptions - { - PropertyNamingPolicy = JsonNamingPolicy.CamelCase - }; - - var myAccess = JsonSerializer.Deserialize>(jsonResponse, options); - return myAccess; - } - else - { - // Handle API request failure - } + PropertyNamingPolicy = JsonNamingPolicy.CamelCase + }; + var myAccess = JsonSerializer.Deserialize>(jsonResponse, options); + return myAccess; } } - // Handle token retrieval failure return null; } catch (Exception ex) @@ -483,6 +472,17 @@ namespace CPRNIMS.Domain.UIServices.Account throw; } } + public async Task> GetLandingPageByUserId(User user) + { + var token = await _tokenHelper.GetValidTokenAsync(); + if (!string.IsNullOrEmpty(token)) + { + // Call the overload + return await GetLandingPageByUserId(user, token); + } + + return null; + } public async Task> GetDepartment(User user) { var token = await _tokenHelper.GetValidTokenAsync(); diff --git a/CPRNIMS.WebApi/CPRNIMS.WebApi.csproj.user b/CPRNIMS.WebApi/CPRNIMS.WebApi.csproj.user index 1803fb7..3340438 100644 --- a/CPRNIMS.WebApi/CPRNIMS.WebApi.csproj.user +++ b/CPRNIMS.WebApi/CPRNIMS.WebApi.csproj.user @@ -9,4 +9,7 @@ ProjectDebugger + + ProjectDebugger + \ No newline at end of file diff --git a/CPRNIMS.WebApi/Controllers/Finance/RRMgmtController.cs b/CPRNIMS.WebApi/Controllers/Finance/RRMgmtController.cs index 1c32f92..86d7ded 100644 --- a/CPRNIMS.WebApi/Controllers/Finance/RRMgmtController.cs +++ b/CPRNIMS.WebApi/Controllers/Finance/RRMgmtController.cs @@ -28,34 +28,16 @@ namespace CPRNIMS.WebApi.Controllers.Finance [HttpPost("GetAllClosedPO")] public async Task GetAllClosedPO(RRDetailsDto itemCodeDto) { - try - { - var allPR = await _rr.GetAllClosedPO(itemCodeDto); + var allPR = await _rr.GetAllClosedPO(itemCodeDto); - return Ok(allPR); - } - catch (Exception ex) - { - var message = ex.InnerException?.ToString() ?? ex.Message.ToString(); - await PostErrorMessage(message, "WebApi"); - throw; - } + return Ok(allPR); } [HttpPost("GetRRDetailByPO")] public async Task GetRRDetailByPO(RRDetailsDto itemDto) { - try - { - var myPR = await _rr.GetRRDetailByPO(itemDto); + var myPR = await _rr.GetRRDetailByPO(itemDto); - return Ok(myPR); - } - catch (Exception ex) - { - var message = ex.InnerException?.ToString() ?? ex.Message.ToString(); - await PostErrorMessage(message, "WebApi"); - throw; - } + return Ok(myPR); } #endregion diff --git a/CPRNIMS.WebApi/Controllers/Receiving/ReceivingController.cs b/CPRNIMS.WebApi/Controllers/Receiving/ReceivingController.cs index f70f409..11f8a9c 100644 --- a/CPRNIMS.WebApi/Controllers/Receiving/ReceivingController.cs +++ b/CPRNIMS.WebApi/Controllers/Receiving/ReceivingController.cs @@ -1,6 +1,5 @@ using CPRNIMS.Domain.Contracts.Items; using CPRNIMS.Domain.Contracts.Receiving; -using CPRNIMS.Domain.Contracts.SMTP; using CPRNIMS.Domain.Services; using CPRNIMS.Infrastructure.Dto.Items; using CPRNIMS.Infrastructure.Helper; diff --git a/CPRNIMS.WebApps/CPRNIMS.WebApps.csproj.user b/CPRNIMS.WebApps/CPRNIMS.WebApps.csproj.user index cacb606..7cd0cfd 100644 --- a/CPRNIMS.WebApps/CPRNIMS.WebApps.csproj.user +++ b/CPRNIMS.WebApps/CPRNIMS.WebApps.csproj.user @@ -6,10 +6,13 @@ root/Common/MVC/Controller RazorViewEmptyScaffolder root/Common/MVC/View - D:\sourcecode\CPRNIMS\CPRNIMS.WebApps\Properties\PublishProfiles\FolderProfile.pubxml + D:\sourcecode\NonInventPurchasing\CPRNIMS.WebApps\Properties\PublishProfiles\FolderProfile1.pubxml 650.4 ProjectDebugger + + ProjectDebugger + \ No newline at end of file diff --git a/CPRNIMS.WebApps/Controllers/Account/AccountController.cs b/CPRNIMS.WebApps/Controllers/Account/AccountController.cs index 1190c4d..a8f2323 100644 --- a/CPRNIMS.WebApps/Controllers/Account/AccountController.cs +++ b/CPRNIMS.WebApps/Controllers/Account/AccountController.cs @@ -260,8 +260,7 @@ namespace CPRNIMS.WebApps.Controllers.Account #region Views public async Task Index() { - await IsAuthenTicated(); - return View(); + return await IsAuthenTicated(); } #endregion } diff --git a/CPRNIMS.WebApps/Controllers/Base/BaseMethod.cs b/CPRNIMS.WebApps/Controllers/Base/BaseMethod.cs index 2bd38cd..9fac11b 100644 --- a/CPRNIMS.WebApps/Controllers/Base/BaseMethod.cs +++ b/CPRNIMS.WebApps/Controllers/Base/BaseMethod.cs @@ -88,7 +88,7 @@ namespace CPRNIMS.WebApps.Controllers.Base ViewBag.UserCompany = User.FindFirst("Company")?.Value; ViewBag.UserRoles = string.Join(",", User.FindAll(ClaimTypes.Role).Select(c => c.Value)); - ViewBag.URLAttachment = User.FindFirst("URLAttachment")?.Value; + ViewBag.URLAttachment = User.FindFirst("URLAttachment")?.Value ?? "Content/Images/UserProfile/404userImage.jpg"; } protected IActionResult GetResponse(T response) diff --git a/CPRNIMS.WebApps/Controllers/HomeController.cs b/CPRNIMS.WebApps/Controllers/HomeController.cs index 54720b1..8199c86 100644 --- a/CPRNIMS.WebApps/Controllers/HomeController.cs +++ b/CPRNIMS.WebApps/Controllers/HomeController.cs @@ -158,23 +158,6 @@ namespace CPRNIMS.WebApps.Controllers var handler = new JwtSecurityTokenHandler(); var jwtToken = handler.ReadJwtToken(login.token); - if (login.expiresInSeconds > 0) - { - expirationTime = DateTime.UtcNow.AddSeconds(login.expiresInSeconds); - } - else if (!string.IsNullOrEmpty(login.token)) - { - - try - { - - if (jwtToken.ValidTo > DateTime.MinValue) - { - expirationTime = jwtToken.ValidTo; - } - } - catch { } - } var claims = new List { @@ -212,8 +195,19 @@ namespace CPRNIMS.WebApps.Controllers new ClaimsPrincipal(identity), authProperties ); + var currentUser = new Infrastructure.Models.Account.User + { + UserId = login.userId, + UserName = login.userName, + FullName = login.fullName, + Company = login.company, + Token = login.token, + MyAccess = string.Join(",", jwtToken.Claims + .Where(c => c.Type == ClaimTypes.Role) + .Select(c => c.Value)) + }; - var userAccess = await _account.GetLandingPageByUserId(GetUser()); + var userAccess = await _account.GetLandingPageByUserId(currentUser, login.token); var landingAction = userAccess?.FirstOrDefault(u => u.AccessTypeId == 1); diff --git a/CPRNIMS.WebApps/Program.cs b/CPRNIMS.WebApps/Program.cs index e6ecc57..28373ee 100644 --- a/CPRNIMS.WebApps/Program.cs +++ b/CPRNIMS.WebApps/Program.cs @@ -1,7 +1,5 @@ using CPRNIMS.Domain.UIServices.Updater; using CPRNIMS.WebApps.Common; -using Microsoft.AspNetCore.Rewrite; -using Microsoft.Extensions.Options; var builder = WebApplication.CreateBuilder(args); @@ -18,7 +16,6 @@ if (!app.Environment.IsDevelopment()) //app.UseRewriter(options); app.UseHttpsRedirection(); app.UseStaticFiles(); -app.UseCors("AllowAll"); app.UseRouting(); app.UseSession(); diff --git a/CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingColumn.js b/CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingColumnV2.js similarity index 82% rename from CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingColumn.js rename to CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingColumnV2.js index e90dfdc..7a849a5 100644 --- a/CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingColumn.js +++ b/CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingColumnV2.js @@ -142,3 +142,37 @@ var colDefForReceivingSKU = [ } }, ]; +var colRRFinance = [ + { data: 'prNo' }, + { data: 'itemNo' }, + { data: 'itemDescription' }, + { data: 'itemCategoryName' }, + { + data: 'quantity', + render: function (data, type, row, meta) { + return numberWithCommas(data); + } + }, + { + data: 'remainingQty', + render: function (data, type, row, meta) { + return numberWithCommas(data); + } + }, + { + data: 'quantityReceived', + render: function (data, type, row, meta) { + return numberWithCommas(data); + } + }, + { data: 'uomName' }, + { + data: 'unitPrice', + render: function (data, type, row, meta) { + return numberWithCommas(data); + } + }, + { data: 'prDetailsId', visible: false }, + { data: 'emailAddress', visible: false }, + { data: 'supplierName', visible: false }, +]; \ No newline at end of file diff --git a/CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingViewV2.js b/CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingViewV3.js similarity index 99% rename from CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingViewV2.js rename to CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingViewV3.js index c4addd8..62008db 100644 --- a/CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingViewV2.js +++ b/CPRNIMS.WebApps/wwwroot/JsFunctions/Receiving/ReceivingViewV3.js @@ -32,13 +32,11 @@ vatRate.style.display = 'none'; amountPHP.style.display = 'none'; } - let btnComplete = document.getElementById('btnComplete'); - let btnIncomplete = document.getElementById('btnIncomplete'); + //let btnComplete = document.getElementById('btnComplete'); + //let btnIncomplete = document.getElementById('btnIncomplete'); let btnClosePO = document.getElementById('btnClosePO'); btnPayment.style.display = 'none'; if (UserRights == 'POApprover' || UserRights == 'LLIFINANCE' || UserRights == 'CnvssAppver') { - btnComplete.style.display = 'none'; - btnIncomplete.style.display = 'none'; btnSubmit.style.display = 'none'; btnReject.style.display = 'none'; dynamicColumn = colRRFinance;