Example #1
0
        public static async Task <Models.ApiViewModels.ApiAccountKycRequest> CheckKycRequest(ILogger logger, ApplicationDbContext context,
                                                                                             UserManager <ApplicationUser> userManager, KycSettings kycSettings, string applicationUserId, string token)
        {
            var jsonBody = JsonConvert.SerializeObject(new { token = token });
            var response = RestUtils.ServiceRequest(kycSettings.KycServerUrl, "status", jsonBody);

            if (response.IsSuccessful)
            {
                var json = JsonConvert.DeserializeObject <Dictionary <string, string> >(response.Content);
                if (json.ContainsKey("status"))
                {
                    var status = json["status"];
                    // update kyc level if complete
                    if (status.ToLower() == viafront3.Models.ApiViewModels.ApiRequestStatus.Completed.ToString().ToLower())
                    {
                        var newLevel = 2;
                        var user     = await userManager.FindByIdAsync(applicationUserId);

                        if (user == null)
                        {
                            return(null);
                        }
                        var userKyc = user.Kyc;
                        if (userKyc == null)
                        {
                            userKyc = new Kyc {
                                ApplicationUserId = user.Id, Level = newLevel
                            };
                            context.Kycs.Add(userKyc);
                        }
                        else if (userKyc.Level < newLevel)
                        {
                            userKyc.Level = newLevel;
                            context.Kycs.Update(userKyc);
                        }
                        context.SaveChanges();
                    }
                    // return to user
                    var model = new viafront3.Models.ApiViewModels.ApiAccountKycRequest
                    {
                        Token      = token,
                        ServiceUrl = $"{kycSettings.KycServerUrl}/request/{token}",
                        Status     = status,
                    };
                    return(model);
                }
            }
            return(null);
        }
Example #2
0
        public async Task UpdateAsync(Kyc entity)
        {
            var temp = Uow.Repository <Kyc>().Count(t => t.KycId == entity.KycId && t.KycVerifyNumber == entity.KycVerifyNumber);

            if (temp != 0)
            {
                entity.KycStatus = true;
                await Uow.RegisterDirtyAsync(entity);

                await Uow.CommitAsync();
            }
            else
            {
                entity.KycStatus = false;
                await Uow.RegisterDirtyAsync(entity);

                await Uow.CommitAsync();
            }
        }
Example #3
0
        public async Task <object> GetBy(Kyc parameters)
        {
            AadharDetail AadharDetail = new AadharDetail();
            var          temp         = await Uow.Repository <AadharDetail>().SingleOrDefaultAsync(t => t.AadharNumber == parameters.UAadharNumber);

            if (temp != null)
            {
                Random rand = new Random();

                parameters.UAadharNumber   = parameters.UAadharNumber;
                parameters.KycVerifyNumber = rand.Next(1000, 9999);
                //parameters.KycStatus = true;
                await Uow.RegisterNewAsync(parameters);

                await Uow.CommitAsync();

                return(await Task.FromResult(parameters.KycId));
            }
            else
            {
                return(await Task.FromResult("not found"));
            }
        }
Example #4
0
 public Task DeleteAsync(Kyc parameters)
 {
     throw new NotImplementedException();
 }
Example #5
0
 public HashSet <string> DeleteValidation(Kyc parameters)
 {
     return(ValidationMessages);
 }
Example #6
0
 public HashSet <string> UpdateValidation(Kyc entity)
 {
     return(ValidationMessages);
 }
Example #7
0
        public async Task AddAsync(Kyc entity)
        {
            await Uow.RegisterNewAsync(entity);

            await Uow.CommitAsync();
        }
Example #8
0
 public Task <object> GetAsync(Kyc parameters)
 {
     throw new NotImplementedException();
 }