Ejemplo n.º 1
0
        public PersonalVerificationViewModel GetPersonalVerification(int Userid)
        {
            try
            {
                var KYCUserData = _personalVerificationRepository.Table.Where(i => i.UserID == Userid).FirstOrDefault();
                PersonalVerificationViewModel modeldata = new PersonalVerificationViewModel();
                if (KYCUserData != null)
                {
                    modeldata.UserId            = KYCUserData.UserID;
                    modeldata.Surname           = KYCUserData.Surname;
                    modeldata.GivenName         = KYCUserData.GivenName;
                    modeldata.ValidIdentityCard = KYCUserData.ValidIdentityCard;
                    modeldata.FrontImage        = KYCUserData.FrontImage;
                    modeldata.BackImage         = KYCUserData.BackImage;
                    modeldata.SelfieImage       = KYCUserData.SelfieImage;
                    modeldata.EnableStatus      = KYCUserData.EnableStatus;
                    modeldata.VerifyStatus      = KYCUserData.VerifyStatus;
                    modeldata.KYCLevelId        = KYCUserData.KYCLevelId;

                    return(modeldata);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
                throw;
            }
        }
Ejemplo n.º 2
0
        public async Task <long> UpdatePersonalVerification(PersonalVerificationViewModel model)
        {
            var GetVerify = _personalVerificationRepository.Table.Where(i => i.UserID == model.UserId && !i.EnableStatus).FirstOrDefault();

            if (GetVerify != null)
            {
                GetVerify.UserID            = model.UserId;
                GetVerify.Surname           = model.Surname;
                GetVerify.GivenName         = model.GivenName;
                GetVerify.ValidIdentityCard = model.ValidIdentityCard;
                GetVerify.FrontImage        = model.FrontImage;
                GetVerify.BackImage         = model.BackImage;
                GetVerify.SelfieImage       = model.SelfieImage;
                GetVerify.EnableStatus      = model.EnableStatus;
                GetVerify.VerifyStatus      = model.VerifyStatus;
                GetVerify.KYCLevelId        = model.KYCLevelId;
                //CreatedDate = DateTime.UtcNow,
                // CreatedBy = model.UserId,
                GetVerify.UpdatedDate = DateTime.UtcNow;
                GetVerify.UpdatedBy   = model.UserId;
                //Status = 0,

                //var personalVerificationdataupdate = new PersonalVerification
                //{
                //   // Id = model.Id,
                //    UserID = model.UserId,
                //    Surname = model.Surname,
                //    GivenName = model.GivenName,
                //    ValidIdentityCard = model.ValidIdentityCard,
                //    FrontImage = model.FrontImage,
                //    BackImage = model.BackImage,
                //    SelfieImage = model.SelfieImage,
                //    EnableStatus = model.EnableStatus,
                //    VerifyStatus = model.VerifyStatus,
                //    KYCLevelId = model.KYCLevelId,
                //    //CreatedDate = DateTime.UtcNow,
                //    // CreatedBy = model.UserId,
                //    UpdatedDate = DateTime.UtcNow,
                //    UpdatedBy = model.UserId,
                //    Status = 0,

                //};
                //return GetVerify;
                _personalVerificationRepository.Update(GetVerify);

                return(GetVerify.Id);
            }
            return(0);
        }
Ejemplo n.º 3
0
        public async Task <long> AddPersonalVerification(PersonalVerificationViewModel model)
        {
            try
            {
                var GetVerify = _personalVerificationRepository.Table.Where(i => i.UserID == model.UserId && !i.EnableStatus).FirstOrDefault();
                if (GetVerify != null)
                {
                    model.Id         = GetVerify.Id;
                    model.UserId     = GetVerify.UserID;
                    model.KYCLevelId = GetVerify.KYCLevelId;

                    return(await UpdatePersonalVerification(model));
                }
                else
                {
                    var personalVerificationdata = new PersonalVerification
                    {
                        UserID            = model.UserId,
                        Surname           = model.Surname,
                        GivenName         = model.GivenName,
                        ValidIdentityCard = model.ValidIdentityCard,
                        FrontImage        = model.FrontImage,
                        BackImage         = model.BackImage,
                        SelfieImage       = model.SelfieImage,
                        EnableStatus      = model.EnableStatus,
                        VerifyStatus      = model.VerifyStatus,
                        CreatedDate       = DateTime.UtcNow,
                        CreatedBy         = model.UserId,
                        KYCLevelId        = _KYCLevelRepository.Table.Where(k => k.KYCName == "Personal Verification" && !k.EnableStatus && !k.IsDelete).FirstOrDefault().Level,
                        //Status = 0,
                    };
                    _personalVerificationRepository.Insert(personalVerificationdata);
                    //_dbContext.SaveChanges();
                    return(personalVerificationdata.Id);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //[AllowAnonymous]
        //[ApiExplorerSettings(IgnoreApi = true)]
        public async Task <IActionResult> PersonalVerification() //(PersonalVerificationViewModel model)
        {
            try
            {
                var httpRequest = Request.Form;
                var user        = await GetCurrentUserAsync();

                int userid = user.Id;

                PersonalVerificationViewModel model = new PersonalVerificationViewModel();
                //model.Id = ;
                //model.UserID =

                if (String.IsNullOrEmpty(httpRequest["IPAddress"].ToString()))
                {
                    return(BadRequest(new PersonalVerificationResponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.IpAddressInvalid, ErrorCode = enErrorCode.Status4020IpInvalid
                    }));
                }
                //// Ip Address Validate or not
                string CountryCode = await _userService.GetCountryByIP(httpRequest["IPAddress"].ToString());

                if (!string.IsNullOrEmpty(CountryCode) && CountryCode == "fail")
                {
                    return(BadRequest(new PersonalVerificationResponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.IpAddressInvalid, ErrorCode = enErrorCode.Status4020IpInvalid
                    }));
                }
                if (String.IsNullOrEmpty(httpRequest["DeviceId"].ToString()))
                {
                    return(BadRequest(new PersonalVerificationResponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.DeviceIdNotFound, ErrorCode = enErrorCode.Status4015DeviceIdNotFound
                    }));
                }

                if (String.IsNullOrEmpty(httpRequest["Mode"].ToString()))
                {
                    return(BadRequest(new PersonalVerificationResponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.ModeNotFound, ErrorCode = enErrorCode.Status4017ModeNotFound
                    }));
                }

                if (String.IsNullOrEmpty(httpRequest["HostName"].ToString()))
                {
                    return(BadRequest(new PersonalVerificationResponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.HostNameNotFound, ErrorCode = enErrorCode.Status4021HostNameNotFound
                    }));
                }



                if (httpRequest.Files.Count == 0)
                {
                    return(BadRequest(new PersonalVerificationResponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.ImageNotAvailable, ErrorCode = enErrorCode.Status4115ImageNotUpload
                    }));
                }
                if (String.IsNullOrEmpty(httpRequest["Surname"].ToString()))
                {
                    return(BadRequest(new PersonalVerificationResponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.Surname, ErrorCode = enErrorCode.Status4126SuranName
                    }));
                }
                if (String.IsNullOrEmpty(httpRequest["GivenName"].ToString()))
                {
                    return(BadRequest(new PersonalVerificationResponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.GivenName, ErrorCode = enErrorCode.Status4127GivenName
                    }));
                }
                if (String.IsNullOrEmpty(httpRequest["ValidIdentityCard"].ToString()))
                {
                    return(BadRequest(new PersonalVerificationResponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.ValidIdentityCard, ErrorCode = enErrorCode.Status4128ValidIdentityCard
                    }));
                }


                model.UserId            = userid;
                model.Surname           = httpRequest["Surname"].ToString();
                model.GivenName         = httpRequest["GivenName"].ToString();
                model.ValidIdentityCard = httpRequest["ValidIdentityCard"].ToString();
                model.EnableStatus      = false;
                model.VerifyStatus      = false;


                foreach (var file in httpRequest.Files)
                {
                    var postedFile = httpRequest.Files[file.Name];
                    if (file.Length > Convert.ToInt64(_configuration["KYCImageSize"]))
                    {
                        if (file.Name == "Front")
                        {
                            return(BadRequest(new PersonalVerificationResponse {
                                ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.FrontImageSizeLarger, ErrorCode = enErrorCode.Status4123FrontImageLarger
                            }));
                        }
                        if (file.Name == "Back")
                        {
                            return(BadRequest(new PersonalVerificationResponse {
                                ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.BackImageSizeLarger, ErrorCode = enErrorCode.Status4124BackImageLarger
                            }));
                        }
                        if (file.Name == "Selfie")
                        {
                            return(BadRequest(new PersonalVerificationResponse {
                                ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.SelfieImageSizeLarger, ErrorCode = enErrorCode.Status4125SelfiImageLarger
                            }));
                        }
                    }
                }
                foreach (var file in httpRequest.Files)
                {
                    var    postedFile     = httpRequest.Files[file.Name];
                    string folderDirctory = model.UserId.ToString();
                    //string webRootPath = _hostingEnvironment.WebRootPath;
                    string webRootPath = _configuration["KYCImagePath"].ToString();
                    //string newPath = Path.Combine(webRootPath, folderDirctory);
                    string newPath = webRootPath + "/" + folderDirctory;
                    if (!Directory.Exists(newPath))
                    {
                        Directory.CreateDirectory(newPath);
                    }

                    //if (file.Length > 0)
                    //{
                    string fileName = ContentDispositionHeaderValue.Parse(postedFile.ContentDisposition).FileName.Trim('"');
                    //fileName = postedFile.FileName;
                    //string fullPath = Path.Combine(newPath, fileName);
                    string fullPath = newPath + "/" + fileName;
                    using (var stream = new FileStream(fullPath, FileMode.Create))
                    {
                        // postedFile.CopyTo(stream);
                        await postedFile.CopyToAsync(stream);
                    }

                    //using (var fileStream = new FileStream(Path.Combine(uploads, file.FileName), FileMode.Create))
                    //{
                    //    await file.CopyToAsync(fileStream);
                    //}

                    // }

                    if (file.Name == "Front")
                    {
                        model.FrontImage = fullPath;
                    }
                    if (file.Name == "Back")
                    {
                        model.BackImage = fullPath;
                    }
                    if (file.Name == "Selfie")
                    {
                        model.SelfieImage = fullPath;
                    }
                }

                long verifyId = await _personalVerificationService.AddPersonalVerification(model);

                if (verifyId > 0)
                {
                    return(Ok(new PersonalVerificationResponse {
                        ReturnCode = enResponseCode.Success, ReturnMsg = EnResponseMessage.PersonalIdentityInsertSuccessfull
                    }));
                }
                return(BadRequest(new PersonalVerificationResponse {
                    ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.PersonalIdentityNotInserted, ErrorCode = enErrorCode.Status4129PersonalIdentityNotInserted
                }));
            }
            catch (Exception ex)
            {
                return(BadRequest(new PersonalVerificationResponse {
                    ReturnCode = enResponseCode.InternalError, ReturnMsg = ex.ToString(), ErrorCode = enErrorCode.Status500InternalServerError
                }));
            }
        }