Esempio n. 1
0
        public VerifyConsentResponseModel VerifyConsent(VerifyConsentRequestModel requestModel)
        {
            Logging.WriteLog(requestModel);
            VerifyConsentResponseModel responseModel = new VerifyConsentResponseModel();

            responseModel.ReferenceNo = requestModel.ReferenceNo;
            try
            {
                if (IsCifExists(requestModel.CustomerNumber, out string oMessage))
                {
                    string sql = $"SELECT TRIM({nameof(DPI2142F1.F1CIF)}) AS {nameof(DPI2142F1.F1CIF)}, TRIM({nameof(DPI2142F1.F1TYP)}) AS {nameof(DPI2142F1.F1TYP)}, " +
                                 $"TRIM({nameof(DPI2142F1.F1COD)}) AS {nameof(DPI2142F1.F1COD)}, TRIM({nameof(DPI2142F1.F1STS)}) AS {nameof(DPI2142F1.F1STS)} " +
                                 $"FROM {appSetting.GetLibrary(nameof(DPI2142F1))}.{nameof(DPI2142F1)} " +
                                 $"WHERE {nameof(DPI2142F1.F1TYP)} = '001' AND {nameof(DPI2142F1.F1CIF)} = '{requestModel.CustomerNumber}' " +
                                 $"ORDER BY {nameof(DPI2142F1.F1UPDT7)} DESC";
                    if (AS400Singleton.Instance.ExecuteSql(sql, out DataTable oDt, out oMessage))
                    {
                        if (oDt.Rows.Count > 0)
                        {
                            foreach (DataRow row in oDt.Rows)
                            {
                                responseModel.CustomerNumber = row[nameof(DPI2142F1.F1CIF)].ToString();
                                responseModel.DocumentType   = row[nameof(DPI2142F1.F1TYP)].ToString();
                                responseModel.DocumentCode   = row[nameof(DPI2142F1.F1COD)].ToString();
                                responseModel.ConsentFlag    = row[nameof(DPI2142F1.F1STS)].ToString();
                            }
                        }
                        else
                        {
                            throw new NotFoundException($"Information on consent");
                        }
                    }
                    else
                    {
                        throw new Exception(oMessage);
                    }
                }
                else
                {
                    throw new Exception(oMessage);
                }
            }
 public VerifyConsentResponseModel VerifyConsent([FromBody] VerifyConsentRequestModel model)
 {
     return(service.VerifyConsent(model));
 }