public HttpResponseMessage InsertOffers([FromBody] MerchantInformationOfferModel model, Int64 merchantId, Int64 contractId, int isCompleted) { using (CreditReportTier mt = new CreditReportTier()) { if (mt.InsertOffers(model, merchantId, contractId, isCompleted)) { return this.Request.CreateResponse(HttpStatusCode.OK); } else { return this.Request.CreateResponse(HttpStatusCode.BadRequest); } } }
public HttpResponseMessage InsertOffers(Int64 offerId, Int64 merchantId, Int64 contractId, int isCompleted) { using (CreditReportTier mt = new CreditReportTier()) { if (mt.SelectOffer(offerId, merchantId, contractId, isCompleted)) { return this.Request.CreateResponse(HttpStatusCode.OK); } else { return this.Request.CreateResponse(HttpStatusCode.BadRequest); } } }
public HttpResponseMessage CompleteTask([FromBody]RetrieveMerchantInformation model, Int64 tasktypeid, Int64 merchantId, Int64 contractId, int iscompleted, int workflowid) { using (CreditReportTier mt = new CreditReportTier()) { if (mt.CompleteTask(model, tasktypeid, merchantId, contractId, iscompleted, workflowid, model.rawData, string.Empty)) { return this.Request.CreateResponse(HttpStatusCode.OK); } else { return this.Request.CreateResponse(HttpStatusCode.BadRequest); } } }
public HttpResponseMessage InsertCreditReport(Int64 merchantId, Int64 contractId, int reporttype, string reportAvailable, string isCompleted = null) { CreditReportModel model = new CreditReportModel(); using (CreditReportTier mt = new CreditReportTier()) { if (mt.PullReportbyId(reporttype, merchantId, contractId, isCompleted, reportAvailable == "true" ? 0 : 1)) { return this.Request.CreateResponse(HttpStatusCode.OK); } else { return this.Request.CreateResponse(HttpStatusCode.BadRequest); } } }
public HttpResponseMessage UpdateOfferEmailFlag(bool isEmailSent, long offerId, long merchantId, long contractId) { using (CreditReportTier mt = new CreditReportTier()) { var r = mt.UpdateOfferEmailFlag(isEmailSent, offerId, merchantId, contractId); return this.Request.CreateResponse(HttpStatusCode.OK, r); } }
public HttpResponseMessage RetrieveOffers(Int64 merchantId, Int64 contractId) { IList<OfferModel> offers; using (CreditReportTier mt = new CreditReportTier()) { offers = (mt.RetrieveOffers(merchantId, contractId)); return this.Request.CreateResponse(HttpStatusCode.OK, offers); } }
public HttpResponseMessage RetrieveMerchantScore(Int64 merchantId, Int64 contractId, Int32 workflowid, Int32 tasktypeid) { DataSet ds; using (CreditReportTier mt = new CreditReportTier()) { ds = (mt.RetrieveInformationforScorin(merchantId)); DataTable MerchantInfo = ds.Tables[0]; MerchantInfo.TableName = "MerchantInfo"; DataTable OwnerInfo = ds.Tables[1]; OwnerInfo.TableName = "Owners"; DataTable Processor = ds.Tables[2]; Processor.TableName = "Processor"; DataTable OwnerCreditInfo = ds.Tables[3]; OwnerCreditInfo.TableName = "OwnerCreditInfo"; DataTable OwnerLoans = ds.Tables[4]; OwnerLoans.TableName = "OwnerLoans"; DataTable OwnerCreditCard = ds.Tables[5]; OwnerCreditCard.TableName = "CreditCard"; DataTable OwnerOthers = ds.Tables[6]; OwnerOthers.TableName = "Other"; DataTable BankStatements = ds.Tables[11]; BankStatements.TableName = "BankStatements"; DataTable CompanyCreditInfo = ds.Tables[7]; CompanyCreditInfo.TableName = "CompanyCreditInfo"; DataTable CompanyLoans = ds.Tables[8]; CompanyLoans.TableName = "CompanyLoans"; DataTable CompanyCreditCard = ds.Tables[9]; CompanyCreditCard.TableName = "CompanyCreditCard"; DataTable CompanyOthers = ds.Tables[10]; CompanyOthers.TableName = "CompanyOthers"; DataTable CCActvity = ds.Tables[12]; CCActvity.TableName = "CreditCardActivity"; DataTable CCVolumes = ds.Tables[13]; CCVolumes.TableName = "CCACCVTotalAmount"; //GenXML(ds); XmlDocument doc = new XmlDocument(); string requestxml = mt.CreateXML(ds); doc.LoadXml(requestxml); XmlElement root = doc.DocumentElement; //Call the service to fetch the report DataviewService.DataviewServiceSoapClient clinet = new DataviewService.DataviewServiceSoapClient(); var report = clinet.ProcessApplicationXML(root); var sr = JsonConvert.SerializeObject(report, Newtonsoft.Json.Formatting.Indented); JObject obj = JObject.Parse(sr); string Score = obj.SelectToken("Response").SelectToken("Score").ToString(); string Roundedscore = obj.SelectToken("Response").SelectToken("ScoreRedondeado").ToString(); string Finalletter = obj.SelectToken("Response").SelectToken("LetraFinal").ToString(); if (mt.CompleteTask(Convert.ToDouble(Score), Convert.ToDouble(Score), Finalletter, tasktypeid, merchantId, contractId, 0, workflowid, sr, requestxml)) { return this.Request.CreateResponse(HttpStatusCode.OK, mt.RetrieveMerchantInformation(merchantId, contractId)); } else { return this.Request.CreateResponse(HttpStatusCode.BadRequest, mt.RetrieveMerchantInformation(merchantId, contractId)); } } }
public HttpResponseMessage RetrieveMerchantInformation(Int64 merchantId, Int64 contractId) { RetrieveMerchantInformation model; using (CreditReportTier mt = new CreditReportTier()) { model = (mt.RetrieveMerchantInformation(merchantId, contractId)); return this.Request.CreateResponse(HttpStatusCode.OK, model); } }
public bool PullReportbyId(int reporttypeId, Int64 merchantId, Int64 contractId, string isCompleted, int reportAvailable) { string strgetjson = ""; string UserName = ConfigurationManager.AppSettings["UserName"]; string PassWord = ConfigurationManager.AppSettings["PassWord"]; string xmlParameters = string.Empty; string TipoId = string.Empty; string Id = string.Empty; if (reportAvailable == 0) { CreditReportModel analysisModel = new CreditReportModel(); analysisModel.isavailable = 0; analysisModel.image = Encoding.ASCII.GetBytes(""); // string dateString = DateTime.Now.ToString("yyyy-MM-dd"); DateTime dt = DateTime.Now; //string.Concat(dateString.Split('-')[2].Substring(0, 4), "-", dateString.Split('-')[1], "-", dateString.Split('-')[0], " 00:00:00"); IFormatProvider culture2 = new System.Globalization.CultureInfo("es-DO", true); analysisModel.timeofreport = dt; analysisModel.monthEvaualted = dt; if (reporttypeId == 1) { analysisModel.type = "O"; } //Company Report else if (reporttypeId == 2) { analysisModel.type = "C"; } return InsertCreditreport(analysisModel, merchantId, contractId, isCompleted); } else { //Get the values on the basis of the parameters CreditReportModel analysisModel = new CreditReportModel(); if (ConfigurationManager.AppSettings["Testing"] == "0") { RetrieveMerchantInformation modelReport = new RetrieveMerchantInformation(); using (CreditReportTier mt = new CreditReportTier()) { modelReport = mt.RetrieveMerchantInformation(merchantId, contractId); } // Owner Report if (reporttypeId == 1) { TipoId = "C"; analysisModel.type = "O"; Id = modelReport.ownerId; } //Company Report else if (reporttypeId == 2) { TipoId = "R"; analysisModel.type = "C"; Id = modelReport.rnc; // Id = "101088575"; } AcmeRuby.clsCaltecServiceSoapClient objServiceReference_AcmeRuby = new AcmeRuby.clsCaltecServiceSoapClient(); strgetjson = objServiceReference_AcmeRuby.GetXmlJsonStr(UserName, PassWord, TipoId, Id, xmlParameters); //strgetjson = compJson; } else { //Owner Report if (reporttypeId == 1) { TipoId = "C"; Id = "22400033001"; //Id = "00113569248"; analysisModel.type = "O"; } //Company Report else if (reporttypeId == 2) { //Id = "103157531"; Id = "101874139"; TipoId = "R"; analysisModel.type = "C"; } AcmeRuby.clsCaltecServiceSoapClient objServiceReference_AcmeRuby = new AcmeRuby.clsCaltecServiceSoapClient(); strgetjson = objServiceReference_AcmeRuby.GetXmlJsonStr(UserName, PassWord, TipoId, Id, xmlParameters); // strgetjson = compJson; } var sr = Newtonsoft.Json.JsonConvert.DeserializeObject(strgetjson); JObject obj = (JObject)sr; var baseToken = obj.SelectToken("c").SelectToken("DCR"); var errorToken = baseToken.SelectToken("ErrorHandling"); if (errorToken.SelectToken("Id").ToString() == "0") { var individualToken = baseToken.SelectToken("Individuo"); analysisModel.isavailable = 1; var securityToken = baseToken.SelectToken("Seguridad"); var creditAnalysisToken = baseToken.SelectToken("AnalisisCrediticio"); var breakDownCreditsToken = baseToken.SelectToken("DesgloseCreditos"); var productToken = breakDownCreditsToken.SelectToken("Producto"); //var accountToken = productToken.SelectToken("Cuenta"); var companyToken = baseToken.SelectToken("Empresa"); #region Company Information if (companyToken != null) { analysisModel.commercialname = companyToken.SelectToken("NombreComercial").ToString(); analysisModel.name = companyToken.SelectToken("Nombre").ToString(); analysisModel.rnc = companyToken.SelectToken("RNC").ToString(); analysisModel.commercialactivity = companyToken.SelectToken("ActividadComercial").ToString(); } else { analysisModel.commercialname = string.Empty; analysisModel.name = string.Empty; analysisModel.rnc = string.Empty; analysisModel.commercialactivity = string.Empty; } #endregion #region Owner Information if (individualToken != null) { analysisModel.firstName = individualToken.SelectToken("Nombres").ToString(); analysisModel.lastName = individualToken.SelectToken("Apellidos").ToString(); analysisModel.name = string.Concat(analysisModel.firstName, analysisModel.lastName); analysisModel.nationality = individualToken.SelectToken("Nacionalidad").ToString(); analysisModel.occupation = individualToken.SelectToken("Ocupacion").ToString(); analysisModel.passport = individualToken.SelectToken("Pasaporte").ToString(); analysisModel.image = Encoding.ASCII.GetBytes(baseToken.SelectToken("Foto").ToString()); if (individualToken.SelectToken("Categoria") != null) { analysisModel.riskCategory = individualToken.SelectToken("Categoria").ToString(); } } else { analysisModel.nationality = string.Empty; analysisModel.occupation = string.Empty; analysisModel.passport = string.Empty; analysisModel.image = Encoding.ASCII.GetBytes(baseToken.SelectToken("Foto").ToString()); } #endregion #region Genral Information if (securityToken.SelectToken("FechaHora") != null) { string dateString = securityToken.SelectToken("FechaHora").ToString(); // DateTime dateTime = new DateTime(Convert.ToInt32(dateString.Split('-')[2].Substring(0, 4)), Convert.ToInt32(dateString.Split('-')[1]), Convert.ToInt32(dateString.Split('-')[0])); dateString = string.Concat(dateString.Split('-')[2].Substring(0, 4), "-", dateString.Split('-')[1], "-", dateString.Split('-')[0], " 00:00:00"); IFormatProvider culture2 = new System.Globalization.CultureInfo("es-DO", true); analysisModel.timeofreport = Convert.ToDateTime(dateString); analysisModel.monthEvaualted = Convert.ToDateTime(dateString); } // analysisModel.rawData = Encoding.ASCII.GetBytes(strgetjson); analysisModel.rawData = strgetjson; analysisModel.probabilityOfDefault = 0d; if (errorToken != null) { analysisModel.errors = errorToken.SelectToken("Description").ToString(); } #endregion #region Credit Analysis string code = string.Empty; JToken accounts = string.Empty; if (productToken != null) { List<JToken> productList; List<CreditAnalysis> crreport = new List<CreditAnalysis>(); if (productToken.Type == JTokenType.Array) { productList = productToken.ToList(); } else { productList = new List<JToken>() { productToken }; } int iotherAccount = 0; foreach (var item in productList) { if (productToken.Type == JTokenType.Array) { code = item.SelectToken("@Id").ToString(); accounts = item.SelectToken("Cuenta"); } else { code = productToken.SelectToken("@Id").ToString(); accounts = productToken.SelectToken("Cuenta"); } var accountsList = accounts; if (accountsList.Type == JTokenType.Array) { foreach (var ceunta in accountsList) { CreditAnalysis analysis = new CreditAnalysis(); //If loan then if (code.Equals("Préstamo")) { analysis.typeofActivity = "1"; analysisModel.numberofLoans = accountsList.Count(); } else if (code.Equals("Tarjeta de Crédito")) { //Credit Card analysis.typeofActivity = "2"; analysisModel.numberofCreditCards = accountsList.Count(); } else { iotherAccount += 1; //Others analysis.typeofActivity = "3"; analysisModel.numberofOthers = iotherAccount; } string status = ceunta.SelectToken("Estatus").SelectToken("#text").ToString(); // if (status == "1") { string affliate = ceunta.SelectToken("Afiliado").ToString(); analysis.currency = ceunta.SelectToken("Moneda").SelectToken("@Des_Moneda").ToString(); string dateString = string.Empty; if (ceunta.SelectToken("FechaApertura") != null) { dateString = string.Concat("01-", ceunta.SelectToken("FechaApertura").ToString()); dateString = string.Concat(dateString.Split('-')[2].Substring(0, 4), "-", dateString.Split('-')[1], "-", dateString.Split('-')[0], " 00:00:00"); analysis.firstcreditdate = dateString; } analysis.consolidateMonth = string.Concat("01-", (ceunta.SelectToken("MesConsolidado").ToString())); if (ceunta.SelectToken("TotalAdeudado") != null) { if (!String.IsNullOrEmpty(ceunta.SelectToken("TotalAdeudado").ToString()) // && ceunta.SelectToken("TotalAdeudado").ToString() != "(1)" ) { double value; double.TryParse(ceunta.SelectToken("TotalAdeudado").ToString(), out value); analysis.loanowedamount = value; // analysis.loanowedamount = Double.Parse((ceunta.SelectToken("TotalAdeudado").ToString())); } } if (ceunta.SelectToken("CreditoAprobado") != null) { if (!String.IsNullOrEmpty(ceunta.SelectToken("CreditoAprobado").ToString())) { analysis.approvedcredit = Double.Parse(((ceunta.SelectToken("CreditoAprobado").ToString()))); } } if (ceunta.SelectToken("Cuota") != null) { if (!String.IsNullOrEmpty(ceunta.SelectToken("Cuota").ToString())) { analysis.loanmonthlypayment = Double.Parse(((ceunta.SelectToken("Cuota").ToString()))); } } if (ceunta.SelectToken("TotalAtraso") != null) { if (!String.IsNullOrEmpty(ceunta.SelectToken("TotalAtraso").ToString())) { analysis.loanlateamount = (((ceunta.SelectToken("TotalAtraso").ToString()))); } } } crreport.Add(analysis); } } else { string dateString = string.Empty; CreditAnalysis analysis = new CreditAnalysis(); if (code.Equals("Préstamo")) { analysis.typeofActivity = "1"; analysisModel.numberofLoans = accountsList.Count(); } else if (code.Equals("Tarjeta de Crédito")) { //Credit Card analysis.typeofActivity = "2"; analysisModel.numberofCreditCards = accountsList.Count(); } else { //Others iotherAccount += 1; analysis.typeofActivity = "3"; analysisModel.numberofOthers = iotherAccount; } if (productToken.Type == JTokenType.Array) analysis.currency = item.SelectToken("Cuenta").SelectToken("Moneda").SelectToken("@Des_Moneda").ToString(); else analysis.currency = productToken.SelectToken("Cuenta").SelectToken("Moneda").SelectToken("@Des_Moneda").ToString(); string status = accountsList.SelectToken("Estatus").SelectToken("#text").ToString(); // if (status == "1") { string affliate = accountsList.SelectToken("Afiliado").ToString(); analysis.currency = accountsList.SelectToken("Moneda").SelectToken("@Des_Moneda").ToString(); if (accountsList.SelectToken("FechaApertura") != null) { dateString = string.Concat("01-", accountsList.SelectToken("FechaApertura").ToString()); dateString = string.Concat(dateString.Split('-')[2].Substring(0, 4), "-", dateString.Split('-')[1], "-", dateString.Split('-')[0], " 00:00:00"); IFormatProvider culture2 = new System.Globalization.CultureInfo("es-DO", true); analysis.firstcreditdate = dateString; } analysis.consolidateMonth = (accountsList.SelectToken("MesConsolidado").ToString()); if (accountsList.SelectToken("TotalAdeudado") != null) { if (!String.IsNullOrEmpty(accountsList.SelectToken("TotalAdeudado").ToString())) { // analysis.loanowedamount +=Double.Parse((ceunta.SelectToken("TotalAdeudado").ToString())); analysis.loanowedamount = Double.Parse((accountsList.SelectToken("TotalAdeudado").ToString())); } } if (accountsList.SelectToken("CreditoAprobado") != null) { if (!String.IsNullOrEmpty(accountsList.SelectToken("CreditoAprobado").ToString())) { //analysis.approvedcredit += Double.Parse(((ceunta.SelectToken("CreditoAprobado").ToString()))); analysis.approvedcredit = Double.Parse(((accountsList.SelectToken("CreditoAprobado").ToString()))); } } if (accountsList.SelectToken("Cuota") != null) { if (!String.IsNullOrEmpty(accountsList.SelectToken("Cuota").ToString())) { analysis.loanmonthlypayment = Double.Parse(((accountsList.SelectToken("Cuota").ToString()))); } } if (accountsList.SelectToken("TotalAtraso") != null) { if (!String.IsNullOrEmpty(accountsList.SelectToken("TotalAtraso").ToString())) { analysis.loanlateamount = (((accountsList.SelectToken("TotalAtraso").ToString()))); } } crreport.Add(analysis); } } } analysisModel.creditAnalysis = crreport; } #endregion return InsertCreditreport(analysisModel, merchantId, contractId, isCompleted); } else { analysisModel.errors = errorToken.SelectToken("Description").ToString(); analysisModel.rawData = strgetjson; analysisModel.isavailable = 0; analysisModel.image = Encoding.ASCII.GetBytes(""); var securityToken = baseToken.SelectToken("Seguridad"); if (securityToken.SelectToken("FechaHora") != null) { string dateString = securityToken.SelectToken("FechaHora").ToString(); // DateTime dateTime = new DateTime(Convert.ToInt32(dateString.Split('-')[2].Substring(0, 4)), Convert.ToInt32(dateString.Split('-')[1]), Convert.ToInt32(dateString.Split('-')[0])); dateString = string.Concat(dateString.Split('-')[2].Substring(0, 4), "-", dateString.Split('-')[1], "-", dateString.Split('-')[0], " 00:00:00"); IFormatProvider culture2 = new System.Globalization.CultureInfo("es-DO", true); analysisModel.timeofreport = Convert.ToDateTime(dateString); analysisModel.monthEvaualted = Convert.ToDateTime(dateString); } return InsertCreditreport(analysisModel, merchantId, contractId, isCompleted); } } }