Example #1
0
        public async Task <ActionResult> Index()
        {
            var clientId = this.GetClientId();

            var viewModel = new KycIndexPageViewModel
            {
                KycStatus = await _kycRepository.GetKycStatusAsync(clientId)
            };

            return(View(viewModel));
        }
Example #2
0
        public async Task <ResponseModel <AuthenticateResponseModel> > Post(AuthenticateModel model)
        {
            if (string.IsNullOrEmpty(model.Email))
            {
                return(ResponseModel <AuthenticateResponseModel> .CreateInvalidFieldError("email", Phrases.FieldShouldNotBeEmpty));
            }

            if (!model.Email.IsValidEmail())
            {
                return(ResponseModel <AuthenticateResponseModel> .CreateInvalidFieldError("email", Phrases.InvalidEmailFormat));
            }

            if (string.IsNullOrEmpty(model.Password))
            {
                return(ResponseModel <AuthenticateResponseModel> .CreateInvalidFieldError("passowrd", Phrases.FieldShouldNotBeEmpty));
            }

            var client = await _clientAccountsRepository.AuthenticateAsync(model.Email, model.Password);

            if (client == null)
            {
                return(ResponseModel <AuthenticateResponseModel> .CreateInvalidFieldError("passowrd", Phrases.InvalidUsernameOrPassword));
            }

            this.AuthenticateUserViaOwin(client);

            return(ResponseModel <AuthenticateResponseModel> .CreateOk(new AuthenticateResponseModel
            {
                KycStatus = (await _kycRepository.GetKycStatusAsync(client.Id)).ToString(),
                PinIsEntered = await _pinSecurityRepository.IsPinEntered(client.Id)
            }));
        }
Example #3
0
        public async Task <KycStatus> UploadDocumentAsync(string clientId, IFormFile document, string type)
        {
            var status = await _kycRepository.GetKycStatusAsync(clientId);

            if (status != KycStatus.NeedToFillData)
            {
                return(status);
            }

            var parsedContentDisposition = ContentDispositionHeaderValue.Parse(document.ContentDisposition);
            var fileName = parsedContentDisposition.FileName.Trim('"');

            var mimeType = document.ContentType;

            using (var fileStream = document.OpenReadStream())
                using (var ms = new MemoryStream())
                {
                    fileStream.CopyTo(ms);
                    var fileBytes = ms.ToArray();

                    await
                    _srvKycManager.UploadDocument(clientId, type, fileName, mimeType, fileBytes, RecordChanger.Client);
                }

            await _clientSettingsRepository.UpdateKycDocumentSettingOnUpload(clientId, type);

            return(status);
        }
Example #4
0
        public async Task <ResponseModel> Post(KycDocumentsModel model)
        {
            if (string.IsNullOrEmpty(model.Type))
            {
                return(ResponseModel.CreateInvalidFieldError("type", Phrases.FieldShouldNotBeEmpty));
            }


            if (!KycDocumentTypes.HasDocumentType(model.Type))
            {
                return(ResponseModel.CreateInvalidFieldError("type", Phrases.InvalidDocumentType));
            }

            if (string.IsNullOrEmpty(model.Ext))
            {
                return(ResponseModel.CreateInvalidFieldError("ext", Phrases.FieldShouldNotBeEmpty));
            }

            if (string.IsNullOrEmpty(model.Data))
            {
                return(ResponseModel.CreateInvalidFieldError("data", Phrases.FieldShouldNotBeEmpty));
            }


            byte[] data;
            try
            {
                data = Convert.FromBase64String(model.Data);
            }
            catch (Exception)
            {
                return(ResponseModel.CreateInvalidFieldError("data", "Base64 format expected"));
            }

            var clientId = this.GetClientId();

            if (string.IsNullOrEmpty(clientId))
            {
                return(ResponseModel.CreateFail(ResponseModel.ErrorCodeType.NotAuthenticated, Phrases.NotAuthenticated));
            }

            var status = await _kycRepository.GetKycStatusAsync(clientId);

            if (status != KycStatus.NeedToFillData)
            {
                return(ResponseModel.CreateFail(ResponseModel.ErrorCodeType.InconsistentData, Phrases.OperationCanNotBePerformed));
            }


            var fileName = "myFile" + model.Ext.AddFirstSymbolIfNotExists('.');
            var mimeType = MimeMapping.GetMimeMapping(fileName);

            await
            _srvKycDocumentsManager.UploadDocument(clientId, model.Type, fileName, mimeType, data);

            return(ResponseModel.CreateOk());
        }
Example #5
0
        public async Task <ResponseModel <KycModelStatusResponseModel> > Get()
        {
            var clientId = this.GetClientId();

            if (string.IsNullOrEmpty(clientId))
            {
                return(ResponseModel <KycModelStatusResponseModel> .CreateFail(ResponseModel.ErrorCodeType.NotAuthenticated, Phrases.NotAuthenticated));
            }

            var kycStatus = await _kycRepository.GetKycStatusAsync(clientId);

            if (kycStatus == KycStatus.Rejected)
            {
                kycStatus = KycStatus.NeedToFillData;
            }

            return(ResponseModel <KycModelStatusResponseModel> .CreateOk(
                       new KycModelStatusResponseModel
            {
                KycStatus = kycStatus.ToString()
            }));
        }
        public async Task <IActionResult> GetKycStatus(string email)
        {
            var applicationId = HttpContext.Request.Headers["application_id"].ToString();
            var app           = await _applicationRepository.GetByIdAsync(applicationId);

            if (app == null)
            {
                return(Json("Application Id Incorrect!"));
            }

            var client = await _clientAccountsRepository.GetByEmailAsync(email);

            var kycStatus = await _kycRepository.GetKycStatusAsync(client.Id);

            return(Json(kycStatus.ToString()));
        }
Example #7
0
        public async Task <ActionResult> FindClient(string phrase)
        {
            var viewModel = new DocumentsCheckingFindClientViewModel
            {
                PersonalData = await _srvClientFinder.FindClientAsync(phrase)
            };

            if (viewModel.PersonalData == null)
            {
                return(View(viewModel));
            }

            viewModel.KycStatus = await _kycRepository.GetKycStatusAsync(viewModel.PersonalData.Id);

            return(View(viewModel));
        }
Example #8
0
        public async Task <bool> ChangeKycStatus(string clientId, KycStatus kycStatus, string changer)
        {
            var currentStatus = await _kycRepository.GetKycStatusAsync(clientId);

            if (currentStatus != kycStatus)
            {
                await _kycRepository.SetStatusAsync(clientId, kycStatus);

                await _auditLogRepository.AddAuditRecordAsync(clientId, currentStatus, kycStatus,
                                                              AuditRecordType.KycStatus, changer);
                await UpdateKycBadge();

                return(true);
            }

            return(false);
        }
Example #9
0
        public async Task <bool> IsKycNeeded(string clientId, string assetId)
        {
            if (string.IsNullOrEmpty(assetId))
            {
                throw new ArgumentException(nameof(assetId));
            }

            var asset = await _assets.GetItemAsync(assetId);

            if (asset == null)
            {
                throw new ArgumentException(nameof(assetId));
            }

            var userKycStatus = await _kycRepository.GetKycStatusAsync(clientId);

            return(asset.KycNeeded && userKycStatus != KycStatus.Ok);
        }