public async Task <IActionResult> CreateKYCData(int profileId, [FromForm] KYCFormData data)
        {
            var kycDataModel = JsonConvert.DeserializeObject <List <KYCCreateData> >(data.KYCData);

            foreach (var kyc in kycDataModel)
            {
                if (kyc.GSTDetailString != null)
                {
                    kyc.Gstdocument = data.GstDoc;
                }
                else
                {
                    if (kyc.Dob != null && kyc.FatherName != null)
                    {
                        kyc.Kycdoc = data.KycDoc;
                    }
                    else
                    {
                        kyc.Proofdocument = data.ProofDoc;
                    }
                }
            }
            CreateKYCDataRequest request = new CreateKYCDataRequest()
            {
                KYCData = kycDataModel
            };
            var result = await kycDetailService.CreateKYCData(profileId, request);

            return(StatusCode((int)result.Code, result.Value));
        }
示例#2
0
        public async Task <IActionResult> CreateKYCData(int profileId, [FromBody] CreateKYCDataRequest request)
        {
            var createKYCDetailCommand = new CreateKYCDataCommand(profileId, request);
            var result = await mediator.Send(createKYCDetailCommand);

            return(StatusCode((int)result.Code, result.Value));
        }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateKYCDataCommand"/> class.
 /// </summary>
 /// <param name="request">The request.</param>
 public CreateKYCDataCommand(int profileId, CreateKYCDataRequest request)
 {
     Request   = request;
     ProfileId = profileId;
 }
        /// <summary>
        /// Creates the kyc data.
        /// </summary>
        /// <param name="profileId">The profile identifier.</param>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public async Task <APIResponse> CreateKYCData(int profileId, CreateKYCDataRequest request)
        {
            try
            {
                string filename   = "";
                var    folderName = Path.Combine("KYCData");
                var    pathToSave = Path.Combine("D:", "HappyWedding", folderName);

                foreach (var item in request.KYCData)
                {
                    if (item.Kycdoc != null)
                    {
                        item.KYCDetails = new List <Core.DTO.Identity.KYCData.KYCDetails>();
                        foreach (var kycPic in item.Kycdoc)
                        {
                            if (kycPic.Length > 0)
                            {
                                string format = System.IO.Path.GetExtension(kycPic.FileName);
                                filename = profileId + "_Kycdoc_" + DateTime.Now + format;
                                string filenme  = filename.Replace(":", ".");
                                var    filePath = Path.Combine(pathToSave, filenme);
                                using var fileStream = new FileStream(filePath, FileMode.Create);
                                kycPic.CopyTo(fileStream);
                                item.KYCDetails.Add(new Core.DTO.Identity.KYCData.KYCDetails {
                                    KycdocPath = filePath
                                });
                            }
                        }
                        item.Kycdoc = null;
                    }
                    if (item.Proofdocument != null)
                    {
                        item.KYCDetails = new List <Core.DTO.Identity.KYCData.KYCDetails>();
                        foreach (var kycPic in item.Proofdocument)
                        {
                            if (kycPic.Length > 0)
                            {
                                string format = System.IO.Path.GetExtension(kycPic.FileName);
                                filename = profileId + "_Proofdocument_" + DateTime.Now + format;
                                string filenme  = filename.Replace(":", ".");
                                var    filePath = Path.Combine(pathToSave, filenme);
                                using var fileStream = new FileStream(filePath, FileMode.Create);
                                kycPic.CopyTo(fileStream);
                                item.KYCDetails.Add(new Core.DTO.Identity.KYCData.KYCDetails {
                                    KycdocPath = filePath
                                });
                            }
                        }
                        item.Proofdocument = null;
                    }
                    if (item.Gstdocument != null)
                    {
                        item.GSTDetails = new List <Core.DTO.Identity.KYCData.GSTDetails>();

                        var gst = JsonConvert.DeserializeObject <Core.DTO.Identity.KYCData.GSTDetails>(item.GSTDetailString);
                        foreach (var kycPic in item.Gstdocument)
                        {
                            if (kycPic.Length > 0)
                            {
                                string format = System.IO.Path.GetExtension(kycPic.FileName);
                                filename = profileId + "_Gstdocument_" + DateTime.Now + format;
                                string filenme  = filename.Replace(":", ".");
                                var    filePath = Path.Combine(pathToSave, filenme);
                                using var fileStream = new FileStream(filePath, FileMode.Create);
                                kycPic.CopyTo(fileStream);
                                item.GSTDetails.Add(new Core.DTO.Identity.KYCData.GSTDetails
                                {
                                    Address      = gst.Address,
                                    BusinessName = gst.BusinessName,
                                    Gstcity      = gst.Gstcity,
                                    Gstnumber    = gst.Gstnumber,
                                    Gststate     = gst.Gststate,
                                    Gstdocument  = filePath
                                });
                            }
                        }
                        item.Gstdocument = null;
                    }
                }
                var client = httpClientFactory.CreateClient(IdentityServiceOperation.serviceName);

                var         param       = JsonConvert.SerializeObject(request);
                HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json");

                var response = await client.PostAsync(servicesConfig.Identity + IdentityServiceOperation.CreateKYCData(profileId), contentPost);

                var kycdetails = JsonConvert.DeserializeObject <KYCDetailResponse>(await response.Content.ReadAsStringAsync());
                return(new APIResponse(kycdetails, HttpStatusCode.Created));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in method 'CreateKYCData()'");
                var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                return(new APIResponse(exMessage, HttpStatusCode.InternalServerError));
            }
        }