From 36e577198a309d52bf3df6039de95a328c4c0246 Mon Sep 17 00:00:00 2001 From: Leeza Baidar Date: Mon, 9 Oct 2023 15:17:04 +0545 Subject: [PATCH] notification view all page --- .../RegisterBusiness/IRegisterBusiness.cs | 3 + .../RegisterBusiness/RegisterBusiness.cs | 7 + .../RegisterRepository/IRegisterRepository.cs | 4 + .../RegisterRepository/RegisterRepository.cs | 64 ++++++- .../Controllers/CustomerController.cs | 19 ++ .../Views/Customer/Notifications.cshtml | 170 ++++++++++++++++++ .../CustomerOnlineV2/Views/Home/Index.cshtml | 4 +- .../Views/Shared/_Layout.cshtml | 2 +- .../Views/Shared/_Layout2.cshtml | 88 ++++++++- 9 files changed, 348 insertions(+), 13 deletions(-) create mode 100644 CustomerOnlineV2/CustomerOnlineV2/Views/Customer/Notifications.cshtml diff --git a/CustomerOnlineV2/CustomerOnlineV2.Business/Business/RegisterBusiness/IRegisterBusiness.cs b/CustomerOnlineV2/CustomerOnlineV2.Business/Business/RegisterBusiness/IRegisterBusiness.cs index 6a02474..a409345 100644 --- a/CustomerOnlineV2/CustomerOnlineV2.Business/Business/RegisterBusiness/IRegisterBusiness.cs +++ b/CustomerOnlineV2/CustomerOnlineV2.Business/Business/RegisterBusiness/IRegisterBusiness.cs @@ -1,4 +1,6 @@ using CustomerOnlineV2.Common.Models; +using CustomerOnlineV2.Common.Models.AccountModel; +using CustomerOnlineV2.Common.Models.HomeModel; using CustomerOnlineV2.Common.Models.RegisterModel; using System; using System.Collections.Generic; @@ -12,5 +14,6 @@ namespace CustomerOnlineV2.Business.Business.RegisterBusiness { Task AddCustomers(OnlineCustomerRegisterModel register); Task GetAddressList(AddressRequest addressRequest); + Task GetAllNotificationDetails(LoginResponse loginDetails); } } diff --git a/CustomerOnlineV2/CustomerOnlineV2.Business/Business/RegisterBusiness/RegisterBusiness.cs b/CustomerOnlineV2/CustomerOnlineV2.Business/Business/RegisterBusiness/RegisterBusiness.cs index e194175..4bb663c 100644 --- a/CustomerOnlineV2/CustomerOnlineV2.Business/Business/RegisterBusiness/RegisterBusiness.cs +++ b/CustomerOnlineV2/CustomerOnlineV2.Business/Business/RegisterBusiness/RegisterBusiness.cs @@ -1,5 +1,7 @@ using CustomerOnlineV2.Api.API.TPApi; using CustomerOnlineV2.Common.Models; +using CustomerOnlineV2.Common.Models.AccountModel; +using CustomerOnlineV2.Common.Models.HomeModel; using CustomerOnlineV2.Common.Models.RegisterModel; using CustomerOnlineV2.Repository.Repository.RegisterRepository; using Microsoft.Extensions.Logging; @@ -37,5 +39,10 @@ namespace CustomerOnlineV2.Business.Business.RegisterBusiness { throw new NotImplementedException(); } + + public async Task GetAllNotificationDetails(LoginResponse loginDetails) + { + return (CustomerNotificationModel)await _registerRepository.GetAllNotificationDetails(loginDetails); + } } } diff --git a/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/RegisterRepository/IRegisterRepository.cs b/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/RegisterRepository/IRegisterRepository.cs index 37b83da..3b5e328 100644 --- a/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/RegisterRepository/IRegisterRepository.cs +++ b/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/RegisterRepository/IRegisterRepository.cs @@ -1,4 +1,6 @@ using CustomerOnlineV2.Common.Models; +using CustomerOnlineV2.Common.Models.AccountModel; +using CustomerOnlineV2.Common.Models.HomeModel; using CustomerOnlineV2.Common.Models.RegisterModel; using System; using System.Collections.Generic; @@ -11,5 +13,7 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository public interface IRegisterRepository { Task AddRegisterDetails(OnlineCustomerRegisterModel register); + // Task AddRegisterDetails(LoginResponse loginDetails); + Task GetAllNotificationDetails(LoginResponse loginDetails); } } diff --git a/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/RegisterRepository/RegisterRepository.cs b/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/RegisterRepository/RegisterRepository.cs index 87f0217..cc237b4 100644 --- a/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/RegisterRepository/RegisterRepository.cs +++ b/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/RegisterRepository/RegisterRepository.cs @@ -1,8 +1,13 @@ using CustomerOnlineV2.Common.Models; +using CustomerOnlineV2.Common.Models.AccountModel; +using CustomerOnlineV2.Common.Models.HomeModel; using CustomerOnlineV2.Common.Models.RegisterModel; using CustomerOnlineV2.Repository.ConnectionHelper; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Reflection; using System.Text; @@ -13,9 +18,11 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository public class RegisterRepository : IRegisterRepository { private readonly IConnectionHelper _connHelper; + private readonly ILogger _logger; - public RegisterRepository(IConnectionHelper connHelper) + public RegisterRepository(ILogger logger, IConnectionHelper connHelper) { + _logger = logger; _connHelper = connHelper; } @@ -86,5 +93,60 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository return await Task.FromResult(model); } + + public async Task GetAllNotificationDetails(LoginResponse loginDetails) + { + CustomerNotificationModel _response = new CustomerNotificationModel(); + try + { + var sql = "EXEC proc_getNotifyInfo"; + sql += " @Flag = " + _connHelper.FilterString("notificationDetail-portal"); + // sql += ",@User = " + _connHelper.FilterString(loginDetails.UserName); + sql += ",@customerId = " + _connHelper.FilterString(loginDetails.UserId); + _logger.LogDebug("HOMEREPOSITORY | GETCUSTOMERNOTIFLIST | SQL | " + sql); + var dt = _connHelper.ExecuteDataTable(sql); + + if (dt == null || dt.Rows.Count <= 0) + { + _response.ResponseCode = ResponseHelper.FAILED; + _response.ResponseMessage = "DB Null Error!"; + + _logger.LogError("HOMEREPOSITORY | GETCUSTOMERNOTIFLIST | DB RESPONSE | " + JsonConvert.SerializeObject(_response)); + } + else + { + _response.ResponseCode = Convert.ToInt16(dt.Rows[0]["errorCode"]); + _response.ResponseMessage = Convert.ToString(dt.Rows[0]["msg"]); + + List obj = new List(); + foreach (DataRow item in dt.Rows) + { + obj.Add(new NotificationModel + { + //Id = Convert.ToString(item["rowId"]), + Title = Convert.ToString(item["title"]), + Body = Convert.ToString(item["body"]), + Date = Convert.ToString(item["createDate"]), + //IsRead = Convert.ToString(item["isRead"]), + //Type = Convert.ToString(item["type"]), + //SentId = Convert.ToString(item["sentId"]), + // Category = Convert.ToString(item["category"]), + //url = Convert.ToString(item["url"]), + //IsClickable = Convert.ToString(item["isClickable"]) + // notificationCount = Convert.ToString(item["notificationCount"]) + }); + } + _response.NotificationModel = obj; + } + } + catch (Exception ex) + { + _response.ResponseCode = ResponseHelper.EXCEPTION; + _response.ResponseMessage = "Exception occured: " + ex.Message; + + _logger.LogError("HOMEREPOSITORY | GETCUSTOMERNOTIFLIST | EXCEPTION | " + JsonConvert.SerializeObject(_response)); + } + return await Task.FromResult(_response); + } } } diff --git a/CustomerOnlineV2/CustomerOnlineV2/Controllers/CustomerController.cs b/CustomerOnlineV2/CustomerOnlineV2/Controllers/CustomerController.cs index 7d4a421..1d0d03b 100644 --- a/CustomerOnlineV2/CustomerOnlineV2/Controllers/CustomerController.cs +++ b/CustomerOnlineV2/CustomerOnlineV2/Controllers/CustomerController.cs @@ -2,12 +2,15 @@ using CustomerOnlineV2.Authorization; using CustomerOnlineV2.Business.Business.RegisterBusiness; using CustomerOnlineV2.Common.Models; +using CustomerOnlineV2.Common.Models.HomeModel; using CustomerOnlineV2.Common.Models.ReceiverModel; using CustomerOnlineV2.Common.Models.RegisterModel; using CustomerOnlineV2.Common.Models.TransactionModel; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using Serilog.Context; +using CustomerOnlineV2.Common.Helper; + namespace CustomerOnlineV2.Controllers { @@ -76,5 +79,21 @@ namespace CustomerOnlineV2.Controllers { return View(); } + + [Authorization("Notifications")] + public IActionResult Notifications() + { + return View(); + } + + [HttpPost] + [ValidateAntiForgeryToken] + [Authorization("GetAllNotifications")] + public async Task GetAllNotifications() + { + var loginDetails = HttpContext.GetLoginDetails(); + + return await _registerBusiness.GetAllNotificationDetails(loginDetails); + } } } diff --git a/CustomerOnlineV2/CustomerOnlineV2/Views/Customer/Notifications.cshtml b/CustomerOnlineV2/CustomerOnlineV2/Views/Customer/Notifications.cshtml new file mode 100644 index 0000000..650982e --- /dev/null +++ b/CustomerOnlineV2/CustomerOnlineV2/Views/Customer/Notifications.cshtml @@ -0,0 +1,170 @@ +@using CustomerOnlineV2.Common.Helper +@{ + Layout = "_Layout2"; +} + + + + + + + + + + +
+
+
+ + + +
+ + + + +
+ +
+
+ + + + +
+ +
+
+
Title
+
Message
+
Date
+ @*
Date
+
Transaction Type
*@ +
+
+ + +
+
+
+
+
+
+ @*
+
*@ +
+
+
+ + + +
+
+ + + + + +
+ + +
+
+
+
+
+
+

+ IME London is a product of Subhida UK Limited, Pentax House,South Hill Avenue, South Harrow, London, H2A 0D + + Company Registration No. 06432399 Subhida UK Ltd is authorized and regulated by the Financial Conduct + Authority (FCA)
under the Payment Service Regulations 2017. FCA Registration No. 576127 HMRC Registration No. XYML000000119350 +

+ +
+
+
+
+
+
+

© IME London, 2023

+
+ +
+
+
+
+
+ +
+ + + + + + +@section scripts{ + + +} \ No newline at end of file diff --git a/CustomerOnlineV2/CustomerOnlineV2/Views/Home/Index.cshtml b/CustomerOnlineV2/CustomerOnlineV2/Views/Home/Index.cshtml index d4fda6e..90752da 100644 --- a/CustomerOnlineV2/CustomerOnlineV2/Views/Home/Index.cshtml +++ b/CustomerOnlineV2/CustomerOnlineV2/Views/Home/Index.cshtml @@ -30,7 +30,7 @@ - *@
diff --git a/CustomerOnlineV2/CustomerOnlineV2/Views/Shared/_Layout.cshtml b/CustomerOnlineV2/CustomerOnlineV2/Views/Shared/_Layout.cshtml index fa5a777..b82c56a 100644 --- a/CustomerOnlineV2/CustomerOnlineV2/Views/Shared/_Layout.cshtml +++ b/CustomerOnlineV2/CustomerOnlineV2/Views/Shared/_Layout.cshtml @@ -99,7 +99,7 @@ -
  • See all Notifications
  • +
  • See all Notifications
  • French
  • -
  • '); + var notificationLink = $('', { + 'class': 'dropdown-item', + 'href': '#' + }); + + var notificationContent = $('
    ', { 'class': 'notification-item' }); + var notificationDate = $('
    ', { 'class': 'notification-date', 'id': 'date' }).text(notification.date); + var notificationTitle = $('
    ', { 'class': 'notification-title', 'id': 'title' }).text(notification.title); + var notificationBody = $('
    ', { 'class': 'notification-body', 'id': 'body' }).text(notification.body); + + notificationContent.append(notificationDate, notificationTitle, notificationBody); + notificationLink.append(notificationContent); + notificationItem.append(notificationLink); + + notificationDetail.append(notificationItem); + } + } + } @await RenderSectionAsync("Scripts", required: false)