Example #1
0
        public Reginfo ConvertCbsPullToregInfo(CbsCustomerInfo cbsCustomerInfo)
        {
            string[] splitDate = cbsCustomerInfo.cBSdbAccount.DOB.Split('T');
            Reginfo  reginfo   = new Reginfo
            {
                Name             = cbsCustomerInfo.cBSdbAccount.CustomeName,
                DateOfBirth      = Convert.ToDateTime(splitDate[0]),
                Gender           = cbsCustomerInfo.cBSdbAccount.Sex,
                FatherName       = cbsCustomerInfo.cBSdbAccount.FathersName,
                MotherName       = cbsCustomerInfo.cBSdbAccount.MotherName,
                Mphone           = cbsCustomerInfo.cBSdbAccount.MobileNumber,
                PerAddr          = cbsCustomerInfo.cBSdbAccount.AddressLine1,
                FirstNomineeName = cbsCustomerInfo.cBSdbAccount.NomineeFullName
            };

            if (!String.IsNullOrEmpty(cbsCustomerInfo.cBSdbAccount.NationalID) && String.IsNullOrEmpty(cbsCustomerInfo.cBSdbAccount.PassportNo))
            {
                reginfo.PhotoId         = cbsCustomerInfo.cBSdbAccount.NationalID.Trim();
                reginfo.PhotoIdTypeCode = 1;
            }
            if (!String.IsNullOrEmpty(cbsCustomerInfo.cBSdbAccount.PassportNo) && String.IsNullOrEmpty(cbsCustomerInfo.cBSdbAccount.NationalID))
            {
                reginfo.PhotoId         = cbsCustomerInfo.cBSdbAccount.PassportNo.Trim();
                reginfo.PhotoIdTypeCode = 2;
            }
            return(reginfo);
        }
Example #2
0
 public bool IsMobilePhoneMatch(string mphone, CbsCustomerInfo cbsCustomerInfo)
 {
     if (string.Equals(mphone, cbsCustomerInfo.cBSdbAccount.MobileNumber))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #3
0
        public async Task <object> GetCbsAccInfo(string mphone, string bankAcNo)
        {
            try
            {
                if (!String.IsNullOrEmpty(mphone) && !String.IsNullOrEmpty(bankAcNo))
                {
                    var customerInfo = _customerSevice.GetCustomerByMphone(mphone);
                    if (customerInfo == null)
                    {
                        CbsApiInfo      apiInfo         = new CbsApiInfo();
                        CbsCustomerInfo cbsCustomerInfo = new CbsCustomerInfo();
                        Reginfo         reginfo         = new Reginfo();
                        dynamic         apiResponse     = null;
                        bool            isMphoneSame    = false;
                        bool            isNidValid      = false;
                        bool            isNidExist      = false;
                        using (var httpClient = new HttpClient())
                        {
                            using (var response = await httpClient.GetAsync(apiInfo.Ip + apiInfo.ApiUrl + bankAcNo))
                            {
                                apiResponse = await response.Content.ReadAsStringAsync();

                                cbsCustomerInfo = JsonConvert.DeserializeObject <CbsCustomerInfo>(apiResponse);
                            }
                        }

                        if (cbsCustomerInfo == null)
                        {
                            return(Ok(new
                            {
                                Status = HttpStatusCode.NotAcceptable,
                                Model = string.Empty,
                                Erros = "No Cbs Account Found"
                            }));
                        }

                        if (cbsCustomerInfo != null)
                        {
                            isMphoneSame = _customerSevice.IsMobilePhoneMatch(mphone, cbsCustomerInfo);
                            reginfo      = _customerSevice.ConvertCbsPullToregInfo(cbsCustomerInfo);
                        }
                        if (!string.IsNullOrEmpty(reginfo.PhotoId))
                        {
                            isNidValid = CheckIsNidIsValid(reginfo.PhotoId);
                            isNidExist = CheckIsNidIsExist(reginfo.PhotoId);
                        }
                        if (!isNidValid)
                        {
                            return(Ok(new
                            {
                                Status = HttpStatusCode.NotAcceptable,
                                Model = string.Empty,
                                Erros = "Invalid Photo Id"
                            }));
                        }
                        if (isNidExist)
                        {
                            return(Ok(new
                            {
                                Status = HttpStatusCode.NotAcceptable,
                                Model = string.Empty,
                                Erros = "Photo Id already exist"
                            }));
                        }
                        if (reginfo.Mphone.Length != 11)
                        {
                            return(Ok(new
                            {
                                Status = HttpStatusCode.NotAcceptable,
                                Model = string.Empty,
                                Erros = "Mobile No Should be 11 digit"
                            }));
                        }
                        if (isMphoneSame)
                        {
                            return(Ok(new
                            {
                                Status = HttpStatusCode.OK,
                                Model = reginfo,
                                Erros = String.Empty
                            }));
                        }
                        else
                        {
                            return(Ok(new
                            {
                                Status = HttpStatusCode.NotAcceptable,
                                Model = string.Empty,
                                Erros = "Mobile No Mismatched"
                            }));
                        }
                    }
                    else
                    {
                        return(Ok(new
                        {
                            Status = HttpStatusCode.NotAcceptable,
                            Model = string.Empty,
                            Erros = "Customer is already Exist"
                        }));
                    }
                }
                else
                {
                    return(Ok(new
                    {
                        Status = HttpStatusCode.NotAcceptable,
                        Model = string.Empty,
                        Erros = "Invalid Input"
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Ok(new
                {
                    Status = HttpStatusCode.ExpectationFailed,
                    Model = string.Empty,
                    Erros = ex.Message.ToString()
                }));
            }
        }