diff --git a/CustomerOnlineV2/CustomerOnlineV2.Business/Business/DocumentBusiness/DocumentBusiness.cs b/CustomerOnlineV2/CustomerOnlineV2.Business/Business/DocumentBusiness/DocumentBusiness.cs index fd08c6e..7a91e66 100644 --- a/CustomerOnlineV2/CustomerOnlineV2.Business/Business/DocumentBusiness/DocumentBusiness.cs +++ b/CustomerOnlineV2/CustomerOnlineV2.Business/Business/DocumentBusiness/DocumentBusiness.cs @@ -1,4 +1,5 @@ -using CustomerOnlineV2.Common.Models.DocumentModel; +using CustomerOnlineV2.Common.Models; +using CustomerOnlineV2.Common.Models.DocumentModel; using CustomerOnlineV2.Repository.Repository.DocumentRepository; using CustomerOnlineV2.Repository.Repository.ReceiverRepository; using System; @@ -13,22 +14,29 @@ namespace CustomerOnlineV2.Business.Business.DocumentBusiness public class DocumentBusiness : IDocumentBusiness { - + private readonly IDocumentRepository _docRepository; public DocumentBusiness(IDocumentRepository docRepository) { - + _docRepository = docRepository; } public string WebRootPath => throw new NotImplementedException(); - public async Task Document(CustomerDocumentModel doc, string Id, string user) + + public async Task GetCustomerImageSavePath(string userId) + { + var model1 = await _docRepository.GetCustomerImageSavePath(userId); + return model1; + } + + public async Task AddCustomerDocument(CustomerDocumentModel doc, string Id, string user) { - var model1 = await _docRepository.GetDocument(doc, Id, user); + var model1 = await _docRepository.AddCustomerDocument(doc, Id, user); return model1; } } diff --git a/CustomerOnlineV2/CustomerOnlineV2.Business/Business/DocumentBusiness/IDocumentBusiness.cs b/CustomerOnlineV2/CustomerOnlineV2.Business/Business/DocumentBusiness/IDocumentBusiness.cs index ee213b3..2e075ee 100644 --- a/CustomerOnlineV2/CustomerOnlineV2.Business/Business/DocumentBusiness/IDocumentBusiness.cs +++ b/CustomerOnlineV2/CustomerOnlineV2.Business/Business/DocumentBusiness/IDocumentBusiness.cs @@ -1,11 +1,12 @@ -using CustomerOnlineV2.Common.Models.DocumentModel; +using CustomerOnlineV2.Common.Models; +using CustomerOnlineV2.Common.Models.DocumentModel; namespace CustomerOnlineV2.Business.Business.DocumentBusiness { public interface IDocumentBusiness { string WebRootPath { get; } - - Task Document(CustomerDocumentModel doc, string userId, string userName); + Task GetCustomerImageSavePath(string userId); + Task AddCustomerDocument(CustomerDocumentModel doc, string userId, string userName); } } \ No newline at end of file diff --git a/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/DocumentRepository/DocumentRepository.cs b/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/DocumentRepository/DocumentRepository.cs index 352020a..c412a09 100644 --- a/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/DocumentRepository/DocumentRepository.cs +++ b/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/DocumentRepository/DocumentRepository.cs @@ -43,7 +43,51 @@ namespace CustomerOnlineV2.Repository.Repository.DocumentRepository // // } //} - public async Task GetDocument(CustomerDocumentModel doc, string id, string user) + public async Task GetCustomerImageSavePath(string userId) + { + CommonResponse doc = new CommonResponse(); + try + { + var sql = "EXEC proc_mobile_StaticData @flag= 'img-path'"; + sql += ", @customerId = " + _connHelper.FilterString(userId); + + + + var dirDetails = _connHelper.ExecuteDataRow(sql); + + if (null == dirDetails) + { + doc.ResponseCode = ResponseHelper.FAILED; + doc.ResponseMessage = "DB Null Error!"; + } + string registrationDate = dirDetails["REGISTERED_DATE"].ToString(); + string membershipId = dirDetails["MEMBERSHIPID"].ToString(); + + if (string.IsNullOrEmpty(registrationDate) || string.IsNullOrEmpty(membershipId)) + { + doc.ResponseCode = ResponseHelper.FAILED; + doc.ResponseMessage = "Invalid Customer Details"; + } + else + { + doc.ResponseCode = ResponseHelper.SUCCESS; + doc.ResponseMessage = ResponseMessageHelper.SUCCESS; + doc.Id = membershipId; + doc.Extra1 = registrationDate; + } + } + catch (Exception ex) + { + doc.ResponseCode = ResponseHelper.EXCEPTION; + doc.ResponseMessage = "Exception occured: " + ex.Message; + + } + + return await Task.FromResult(doc); + + + } + public async Task AddCustomerDocument(CustomerDocumentModel doc, string id, string user) { try { diff --git a/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/DocumentRepository/IDocumentRepository.cs b/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/DocumentRepository/IDocumentRepository.cs index b5635f6..aeb8bc6 100644 --- a/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/DocumentRepository/IDocumentRepository.cs +++ b/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/DocumentRepository/IDocumentRepository.cs @@ -1,10 +1,12 @@ -using CustomerOnlineV2.Common.Models.DocumentModel; +using CustomerOnlineV2.Common.Models; +using CustomerOnlineV2.Common.Models.DocumentModel; namespace CustomerOnlineV2.Repository.Repository.DocumentRepository { public interface IDocumentRepository { //void ExecuteStoredProcedure(string fileName); - Task GetDocument(CustomerDocumentModel doc, string? id, string? user); + Task GetCustomerImageSavePath(string userId); + Task AddCustomerDocument(CustomerDocumentModel doc, string? id, string? user); } } \ No newline at end of file diff --git a/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/HomeRepository/HomeRepository.cs b/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/HomeRepository/HomeRepository.cs index 365efb0..baa60d4 100644 --- a/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/HomeRepository/HomeRepository.cs +++ b/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/HomeRepository/HomeRepository.cs @@ -99,12 +99,14 @@ namespace CustomerOnlineV2.Repository.Repository.HomeRepository obj.Add(new CustomerTransaction { Id = Convert.ToString(item["Id"]), - Amount = Convert.ToString(item["Amount"]), + cAmt = Utilities.ShowDecimal(item["CAmount"].ToString()), + Amount = Utilities.ShowDecimal(Convert.ToString(item["Amount"])), receiverName = Convert.ToString(item["receiverName"]), PaymentMethod = Convert.ToString(item["PaymentMethod"]), ControlNo = Convert.ToString(item["controlNo"]), PBankName = Convert.ToString(item["PBankName"]), PCurrency = Convert.ToString(item["PCurrency"]), + CollCurr = Convert.ToString(item["collCurr"]), TransactionDay = Convert.ToString(item["TransactionDay"]), TransactionMonth = Convert.ToString(item["TransactionMonth"]), Status = Convert.ToString(item["Status"]) @@ -340,30 +342,32 @@ namespace CustomerOnlineV2.Repository.Repository.HomeRepository { if (ds.Tables.Count > 0) { + var dt = ds.Tables[0]; - _response.ResponseCode = Convert.ToInt16(dt.Rows[0]["errorCode"]); - _response.ResponseMessage = Convert.ToString(dt.Rows[0]["msg"]); + _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 + List obj = new List(); + foreach (DataRow item in dt.Rows) { - //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; + 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; } + if (ds.Tables.Count > 1) { _response.RewardAmount = ds.Tables[1].Rows[0]["RewardAmount"].ToString(); diff --git a/CustomerOnlineV2/CustomerOnlineV2/Controllers/CustomerController.cs b/CustomerOnlineV2/CustomerOnlineV2/Controllers/CustomerController.cs index 6d6c13e..00d2ead 100644 --- a/CustomerOnlineV2/CustomerOnlineV2/Controllers/CustomerController.cs +++ b/CustomerOnlineV2/CustomerOnlineV2/Controllers/CustomerController.cs @@ -3,11 +3,13 @@ using CustomerOnlineV2.Authorization; using CustomerOnlineV2.Business.Business.RegisterBusiness; using CustomerOnlineV2.Common.Models; using CustomerOnlineV2.Common.Helper; + using CustomerOnlineV2.Common.Models.ReceiverModel; using CustomerOnlineV2.Common.Models.RegisterModel; using CustomerOnlineV2.Common.Models.TransactionModel; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; + using CustomerOnlineV2.Common.Helper; using CustomerOnlineV2.Common.Models.HomeModel; using CustomerOnlineV2.Common.Models.ReceiverModel; @@ -21,7 +23,7 @@ namespace CustomerOnlineV2.Controllers private readonly IRegisterBusiness _registerBusiness; private readonly ILogger _logger; private readonly ITPApiService _tpApiService; - + public CustomerController(ILogger logger, ITPApiService tpApiService , IRegisterBusiness registerBusiness) { _logger = logger; @@ -29,15 +31,12 @@ namespace CustomerOnlineV2.Controllers _registerBusiness = registerBusiness; } - //[BindProperty] - //public OnlineCustomerRegisterModel Input { get; set; } ///[Authorization("Customer")] public IActionResult CustomerRegistration() { return View(); } - [HttpPost] //[Authorization("AddCustomer")] [ValidateAntiForgeryToken] @@ -58,7 +57,6 @@ namespace CustomerOnlineV2.Controllers // return _response; } - [HttpPost] public async Task GetAddressByPostCode([FromBody] string postalCode) { @@ -80,39 +78,18 @@ namespace CustomerOnlineV2.Controllers return Json(jsonResponse); } + + + public async Task Success() { + return View(); } + + [Authorization("CustomerProfile")] public async Task CustomerProfile(CustomerList customer) { - //var staticDataResponse = _registerBusiness.GetTranCustomerById(customer); - - //var viewModel = new CustomerList - //{ - // Email = na, - // otp = "", - //}; - //if (staticDataResponse.ErrorCode == "0" && staticDataResponse.Extra3.Equals("100")) - //{ - // ViewBag.ResponseCode = "0"; - // ViewBag.ResponseMessage = "OTP has been sent."; - // return View(viewModel); - //} - //else - //{ - // if (staticDataResponse.Extra3.Equals("103")) - // { - // ViewBag.ResponseCode = "103"; - // ViewBag.ResponseMessage = "OTP already has been sent."; - // return View(viewModel); - // } - // ViewBag.ResponseCode = staticDataResponse.ErrorCode; - // ViewBag.ResponseMessage = staticDataResponse.Msg; - // _logger.LogError("ACCOUNTCONTROLLER | REQUESTOTP | ERROR OCCURED | " + JsonConvert.SerializeObject(staticDataResponse)); - // return View(viewModel); - //} - return View(); } [HttpGet] @@ -123,10 +100,10 @@ namespace CustomerOnlineV2.Controllers return await _registerBusiness.GetTranCustomerById(loginDetails); } + [Authorization("Notifications")] public IActionResult Notifications() { - return View(); } @@ -139,7 +116,6 @@ namespace CustomerOnlineV2.Controllers return await _registerBusiness.GetAllNotificationDetails(loginDetails); } - [HttpPost] [Authorization("UpdateCustomer")] @@ -150,24 +126,28 @@ namespace CustomerOnlineV2.Controllers var customer1 = await _registerBusiness.UpdateCustomers(customer, loginDetails.UserId); return customer1; } + [Authorization("Refer")] public IActionResult Refer() { return View(); } + [HttpGet] [Route("GetRewardDetails")] public async Task GetRewardDetails() { var loginDetails = HttpContext.GetLoginDetails(); - //ReceiverInformationModel _response = new ReceiverInformationModel(); + return await _registerBusiness.GetRewardPoints(loginDetails); } + [HttpPost] [Authorization("UpdateDocument")] public async Task UpdateDocument(CustomerListModel customer, string id) { var loginDetails = HttpContext.GetLoginDetails(); + //ReceiverInformationModel _response = new ReceiverInformationModel(); var customer1 = await _registerBusiness.UpdateDocuments(customer, loginDetails.UserId); return customer1; } @@ -178,31 +158,14 @@ namespace CustomerOnlineV2.Controllers var loginDetails = HttpContext.GetLoginDetails(); return await _registerBusiness.GetRewardAmount(loginDetails); } + + [HttpGet] [Route("ValidateReferralCode/{referralCode}")] public async Task ValidateReferralCode(string referralCode) - - { - //var loginDetails = HttpContext.GetLoginDetails(); - //ReceiverInformationModel _response = new ReceiverInformationModel(); + return await _registerBusiness.ValidateReferralCode(referralCode); } - //[HttpPost] - ////[ApplicationLevelAuthentication] - //[Route("mobile/validateReferralCode")] - //public IHttpActionResult ValidateReferralCode(validateReferralCodeRequest request) - //{ - // LogicalThreadContext.Properties[LoggerProperty.CREATEDBY] = request.referralCode; - // LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "ValidateReferralCode"; - // LogicalThreadContext.Properties[LoggerProperty.IPADDRESS] = Request.GetClientIpAddress(); - // Log.Debug("ValidateReferralCode | REQUEST : " + JsonConvert.SerializeObject(request)); - // if (ModelState.IsValid) - // { - // var response = _requestServices.ValidateReferralCode(request.referralCode); - // return Ok(response); - // } - // return ModelValidationError(ModelState); - //} } } diff --git a/CustomerOnlineV2/CustomerOnlineV2/Controllers/CustomerDocumentController.cs b/CustomerOnlineV2/CustomerOnlineV2/Controllers/CustomerDocumentController.cs index 559498a..60b8714 100644 --- a/CustomerOnlineV2/CustomerOnlineV2/Controllers/CustomerDocumentController.cs +++ b/CustomerOnlineV2/CustomerOnlineV2/Controllers/CustomerDocumentController.cs @@ -6,6 +6,8 @@ using CustomerOnlineV2.Business.Business.DocumentBusiness; using Microsoft.AspNetCore.Hosting; using System.Reflection; using CustomerOnlineV2.Authorization; +using System.IO; +using Serilog; namespace CustomerOnlineV2.Controllers { @@ -23,13 +25,52 @@ namespace CustomerOnlineV2.Controllers return View(); } + public static string GetTimestamp(DateTime value) + { + return value.ToString("yyyyMMddHHmmssffff"); + } + private static string SaveFileToPath(IFormFile file, string membershipId, string extension, string img, string registrationDate) + { + string fileName = ""; + + string docUploadPath = ApplicationConfig.GetDocumentUploadPath(); + // Get the file size + + fileName = "upload-" + img + "-" + GetTimestamp(DateTime.Now) + extension; + docUploadPath = docUploadPath + "/CustomerDocument/" + registrationDate.Replace("_", "/") + "/" + membershipId; + Log.Debug("Preparing file to save in dir " + docUploadPath); + if (!Directory.Exists(docUploadPath)) + Directory.CreateDirectory(docUploadPath); + + + + if (file.Length > 0) + { + string filePath = Path.Combine(docUploadPath, file.FileName); + using (Stream fileStream = new FileStream(filePath, FileMode.Create)) + { + file.CopyToAsync(fileStream); + } + } + + Log.Debug("Done with Saving "); + return fileName; + } [HttpPost] - [Authorization("AddDocment")] - public async Task AddDocment(CustomerDocumentModel doc, string id, string user) + [Authorization("AddDocument")] + public async Task AddDocument(CustomerDocumentModel doc, IFormFile MyUploader) { var loginDetails = HttpContext.GetLoginDetails(); + + var cd= await _business.GetCustomerImageSavePath(loginDetails.Email); + + doc.fileName = MyUploader.FileName; + + SaveFileToPath(MyUploader, cd.Id, Path.GetExtension(MyUploader.FileName), MyUploader.FileName, cd.Extra1); + + //ReceiverInformationModel _response = new ReceiverInformationModel(); - var Document = await _business.Document(doc, loginDetails.UserId, loginDetails.UserName); + var Document = await _business.AddCustomerDocument(doc, loginDetails.UserId, loginDetails.Email); //if (ModelState.IsValid) diff --git a/CustomerOnlineV2/CustomerOnlineV2/Controllers/TransactionReportController.cs b/CustomerOnlineV2/CustomerOnlineV2/Controllers/TransactionReportController.cs index 96733fb..fdea4cd 100644 --- a/CustomerOnlineV2/CustomerOnlineV2/Controllers/TransactionReportController.cs +++ b/CustomerOnlineV2/CustomerOnlineV2/Controllers/TransactionReportController.cs @@ -20,6 +20,7 @@ namespace CustomerOnlineV2.Controllers public IActionResult TranReport() { + @ViewBag.ResponseCode = "0"; return View(); } [HttpPost] @@ -27,6 +28,7 @@ namespace CustomerOnlineV2.Controllers [Authorization("GetTransactionReportList")] public async Task GetTransactionReportList(CustomerTransaction model) { + @ViewBag.ResponseCode = "1"; var loginDetails = HttpContext.GetLoginDetails(); return await _transactionBusiness.GetTransactionReportList(loginDetails, model); } diff --git a/CustomerOnlineV2/CustomerOnlineV2/Views/Customer/CustomerProfile.cshtml b/CustomerOnlineV2/CustomerOnlineV2/Views/Customer/CustomerProfile.cshtml index 55a7fa6..5fce069 100644 --- a/CustomerOnlineV2/CustomerOnlineV2/Views/Customer/CustomerProfile.cshtml +++ b/CustomerOnlineV2/CustomerOnlineV2/Views/Customer/CustomerProfile.cshtml @@ -1,5 +1,4 @@ -@model CustomerOnlineV2.Common.Models.RegisterModel.OnlineCustomerRegisterModel - +@model CustomerOnlineV2.Common.Models.RegisterModel.OnlineCustomerRegisterModel @using CustomerOnlineV2.Common.Helper @{ Layout = "_Layout2"; @@ -37,7 +36,7 @@
- @* *@ + @* *@
@@ -71,8 +70,8 @@

Personal Details - @* - Edit + @* + Edit *@


@@ -84,23 +83,22 @@

- +

- +

- +

-

@@ -117,14 +115,13 @@
-

Personal Address - @* - Edit + @* + Edit *@ Edit @@ -134,10 +131,10 @@

City:

@@ -146,7 +143,7 @@

Address1:

- +

@@ -166,19 +163,18 @@
- +

Account Setting @@ -273,35 +270,33 @@
@*
- - + +
*@
-
- +
- +
- +
- +
@@ -312,7 +307,7 @@

Valid ID Card(BRP Card / Passport / Driving License)

- +

Add

@@ -323,8 +318,7 @@