Пример #1
0
        public object Save([FromBody] CustomerRequest model)
        {
            try
            {
                if (model.ReqDate != null)
                {
                    switch (model.Status)
                    {
                    case "C":
                        customerReqLogService.updateRequestLog(model);
                        break;

                    case "P":
                        customerReqLogService.updateRequestLog(model);
                        break;

                    case "O":
                        customerReqLogService.updateRequestLog(model);
                        break;

                    case "Y":
                        customerReqLogService.deleteRequestLog(model);
                        model.CheckedBy = model.HandledBy;
                        customerRequestService.Add(model);
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    CustomerReqLog reqModel = new CustomerReqLog()
                    {
                        ReqDate   = DateTime.Now,
                        CheckedBy = model.CheckedBy,
                        Mphone    = model.Mphone,
                        Remarks   = model.Remarks,
                        Status    = model.Status,
                        Request   = model.Request,
                        Gid       = Guid.NewGuid().ToString()
                    };
                    AuditTrail auditTrail = new AuditTrail();
                    auditTrail.Who                = model.CheckedBy;
                    auditTrail.WhatActionId       = 3;
                    auditTrail.WhichParentMenuId  = 2;
                    auditTrail.WhichMenu          = "Client Profile";
                    auditTrail.WhichId            = model.Mphone;
                    auditTrail.Response           = "Success! Request Generated Successfully";
                    auditTrail.InputFeildAndValue = auditTrailService.GetAuditTrialFeildBySingleObject(model);
                    auditTrailService.InsertIntoAuditTrail(auditTrail);
                    return(customerReqLogService.Add(reqModel));
                }
                return(model);
            }
            catch (Exception ex)
            {
                return(errorLogService.InsertToErrorLog(ex, MethodBase.GetCurrentMethod().Name, Request.Headers["UserInfo"].ToString()));
            }
        }
Пример #2
0
        public object PinReset([FromBody] Reginfo model, bool isUnlockRequest = false)
        {
            try
            {
                int fourDigitRandomNo = new Random().Next(1000, 9999);
                model.UpdateDate = DateTime.Now;
                CustomerRequest customerRequest = new CustomerRequest
                {
                    Mphone    = model.Mphone,
                    ReqDate   = DateTime.Now,
                    HandledBy = model.UpdateBy,
                    Remarks   = model.Remarks,
                    Request   = "Pin Reset",
                    Status    = "Y"
                };
                Reginfo prevAReginfo = (Reginfo)_kycService.GetRegInfoByMphone(model.Mphone);
                _DsrService.UpdatePinNo(model.Mphone, fourDigitRandomNo.ToString());
                customerRequestService.Add(customerRequest);
                var convertedModel = GetConvertedReginfoModel(model);
                _distributorService.UpdateRegInfo(convertedModel);
                Reginfo currentReginfo = (Reginfo)_kycService.GetRegInfoByMphone(model.Mphone);
                var     diffList       = auditTrailService.GetAuditTrialFeildByDifferenceBetweenObject(currentReginfo, prevAReginfo);
                if (!isUnlockRequest)
                {
                    AuditTrail auditTrail = new AuditTrail();
                    auditTrail.Who                = model.UpdateBy;
                    auditTrail.WhatActionId       = 4;
                    auditTrail.WhichParentMenuId  = 2;
                    auditTrail.WhichMenu          = "KYC Profile";
                    auditTrail.InputFeildAndValue = diffList;
                    auditTrail.WhichId            = model.Mphone;
                    auditTrail.Response           = "Success! Pin Reset Successfully";
                    auditTrailService.InsertIntoAuditTrail(auditTrail);
                }
                else
                {
                    AuditTrail auditTrail = new AuditTrail();
                    auditTrail.Who                = model.UpdateBy;
                    auditTrail.WhatActionId       = 4;
                    auditTrail.WhichParentMenuId  = 2;
                    auditTrail.WhichMenu          = "KYC Profile";
                    auditTrail.InputFeildAndValue = diffList;
                    auditTrail.WhichId            = model.Mphone;
                    auditTrail.Response           = "Success! Account Unlocked Successfully";
                    auditTrailService.InsertIntoAuditTrail(auditTrail);
                }

                string messagePrefix = isUnlockRequest == true ? "Your Account Has been Unlocked. Your new Pin is " : "Your Pin has successfully been reset to ";

                MessageModel messageModel = new MessageModel()
                {
                    Mphone      = model.Mphone,
                    MessageId   = "999",
                    MessageBody = "Dear User, " + messagePrefix + fourDigitRandomNo.ToString() + ". Thank you for using OKWallet."
                };

                MessageService messageService = new MessageService();
                messageService.SendMessage(messageModel);

                return(HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                errorLogService.InsertToErrorLog(ex, MethodBase.GetCurrentMethod().Name, Request.Headers["UserInfo"].ToString());
                return(HttpStatusCode.BadRequest);
            }
        }
Пример #3
0
        public object SaveCustomer(Reginfo aReginfo, bool isEdit, string evnt)
        {
            int fourDigitRandomNo = new Random().Next(1000, 9999);

            try
            {
                object  prevModel      = null;
                object  currentModel   = null;
                object  reginfoModel   = null;
                Reginfo convertedModel = null;
                if (isEdit != true)
                {
                    aReginfo.CatId      = "C";
                    aReginfo.PinStatus  = "N";
                    aReginfo.AcTypeCode = 2;
                    aReginfo.RegSource  = "P";
                    aReginfo.EntryDate  = System.DateTime.Now;
                    //aReginfo.RegDate = aReginfo.RegDate + DateTime.Now.TimeOfDay;
                    aReginfo.RegDate = System.DateTime.Now;
                    aReginfo.Mphone  = aReginfo.Mphone.Trim();
                    aReginfo.PhotoId = aReginfo.PhotoId.Trim();
                    try
                    {
                        reginfoModel = kycService.GetRegInfoByMphone(aReginfo.Mphone);
                        bool photoIdValid = (bool)kycService.CheckNidValidWithIdType(aReginfo.PhotoId, "C", aReginfo.PhotoIdTypeCode);
                        if (!photoIdValid)
                        {
                            return("IDEXIST");
                        }
                        if (reginfoModel == null)
                        {
                            if (string.IsNullOrEmpty(aReginfo.EntryBy))
                            {
                                return(HttpStatusCode.Unauthorized);
                            }
                            if (aReginfo.Mphone.Length != 11)
                            {
                                return(HttpStatusCode.BadRequest);
                            }
                            _customerRepository.Add(aReginfo);
                            kycService.UpdatePinNo(aReginfo.Mphone, fourDigitRandomNo.ToString());
                            kycService.InsertModelToAuditTrail(aReginfo, aReginfo.EntryBy, 3, 3, "Customer", aReginfo.Mphone, "Save successfully");
                            MessageService service = new MessageService();
                            service.SendMessage(new MessageModel()
                            {
                                Mphone      = aReginfo.Mphone,
                                MessageId   = "999",
                                MessageBody = "Congratulations! Your OK wallet has been opened successfully." + " Your Pin is "
                                              + fourDigitRandomNo.ToString() + ", please change PIN to activate your account, "
                            });
                        }
                        else
                        {
                            return("DATAEXIST");
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }

                    return(HttpStatusCode.OK);
                }
                else
                {
                    if (evnt == "reject")
                    {
                        var checkStatus = kycService.CheckPinStatus(aReginfo.Mphone);
                        if (checkStatus.ToString() != "P")
                        {
                            aReginfo.UpdateDate = System.DateTime.Now;
                            aReginfo.RegStatus  = "R";
                            CustomerRequest customerRequest = new CustomerRequest
                            {
                                Mphone    = aReginfo.Mphone,
                                ReqDate   = DateTime.Now,
                                HandledBy = aReginfo.UpdateBy,
                                Remarks   = aReginfo.Remarks,
                                Request   = "Reject",
                                Status    = "Y"
                            };
                            if (string.IsNullOrEmpty(aReginfo.UpdateBy))
                            {
                                return(HttpStatusCode.Unauthorized);
                            }
                            customerRequestService.Add(customerRequest);
                            prevModel = kycService.GetRegInfoByMphone(aReginfo.Mphone);
                            _customerRepository.UpdateRegInfo(aReginfo);
                            currentModel = kycService.GetRegInfoByMphone(aReginfo.Mphone);
                            kycService.InsertUpdatedModelToAuditTrail(currentModel, prevModel, aReginfo.UpdateBy, 3, 4, "Customer", aReginfo.Mphone, "Reject successfully");
                            return(HttpStatusCode.OK);
                        }
                        return(HttpStatusCode.OK);
                    }
                    else if (evnt == "edit")
                    {
                        if (string.IsNullOrEmpty(aReginfo.UpdateBy))
                        {
                            return(HttpStatusCode.Unauthorized);
                        }
                        aReginfo.UpdateDate = System.DateTime.Now;
                        convertedModel      = GetConvertedReginfoModel(aReginfo);
                        prevModel           = kycService.GetRegInfoByMphone(aReginfo.Mphone);
                        if (!string.IsNullOrEmpty(convertedModel.PhotoId))
                        {
                            string photoIdPrev               = prevModel.GetType().GetProperty("PhotoId").GetValue(prevModel, null).ToString();
                            string photoIdTypeCodePrev       = prevModel.GetType().GetProperty("PhotoIdTypeCode").GetValue(prevModel, null).ToString();
                            int    photoIdTypeCodeIntPrev    = Convert.ToInt32(photoIdTypeCodePrev);
                            string photoIdCurrent            = convertedModel.PhotoId;
                            int?   photoIdTypeCodeIntCurrent = convertedModel.PhotoIdTypeCode;
                            if ((photoIdCurrent != photoIdPrev) || (photoIdTypeCodeIntPrev != photoIdTypeCodeIntCurrent))
                            {
                                bool photoIdValid = (bool)kycService.CheckNidValidWithIdType(photoIdCurrent, "C", convertedModel.PhotoIdTypeCode);
                                if (!photoIdValid)
                                {
                                    return("IDEXIST");
                                }
                            }
                        }
                        _customerRepository.UpdateRegInfo(convertedModel);
                        currentModel = kycService.GetRegInfoByMphone(aReginfo.Mphone);
                        kycService.InsertUpdatedModelToAuditTrail(currentModel, prevModel, aReginfo.UpdateBy, 3, 4, "Customer", aReginfo.Mphone, "Update successfully");
                        return(HttpStatusCode.OK);
                    }
                    else
                    {
                        var checkStatus = kycService.CheckPinStatus(aReginfo.Mphone);

                        if (checkStatus.ToString() != "P")
                        {
                            aReginfo.RegStatus = "P";
                            aReginfo.AuthoDate = System.DateTime.Now;
                            //aReginfo.RegDate = kycService.GetRegDataByMphoneCatID(aReginfo.Mphone, "C");
                            if (string.IsNullOrEmpty(aReginfo.AuthoBy))
                            {
                                return(HttpStatusCode.Unauthorized);
                            }
                            prevModel = kycService.GetRegInfoByMphone(aReginfo.Mphone);
                            _customerRepository.UpdateRegInfo(aReginfo);
                            currentModel = kycService.GetRegInfoByMphone(aReginfo.Mphone);
                            kycService.InsertUpdatedModelToAuditTrail(currentModel, prevModel, aReginfo.AuthoBy, 3, 4, "Customer", aReginfo.Mphone, "Register successfully");
                            MessageService service = new MessageService();
                            service.SendMessage(new MessageModel()
                            {
                                Mphone      = aReginfo.Mphone,
                                MessageId   = "999",
                                MessageBody = "Dear Customer, Your OK wallet has been Activated successfully. For query, please call at OBL Call Centre: 16269, "
                            });

                            return(HttpStatusCode.OK);
                        }
                        else
                        {
                            return(HttpStatusCode.OK);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }