public IHttpActionResult Get(string id) { var card = new data_validation.net.Web.Controllers.Helpers.RemoveSpecialCharacters(); var cleanNumber = card.RemoveSpecialCharactersCard(id); var userIp = Request.GetOwinContext().Request.RemoteIpAddress; var userHost = Request.GetOwinContext().Request.Host.Value.ToString(); var isFraud = new IsFraudController(); var isFraudUser = isFraud.Check(User.Identity.Name, userIp, userHost); if (isFraudUser) { var errorMessage = new List<CardValidationViewModel>(); errorMessage.Add(new CardValidationViewModel { IsValid = "Fraud Triger On!" }); return Ok(errorMessage); } var helper = new data_validation.net.Web.Controllers.Helpers.CreditsDeduct(); var hasCredits = helper.IsValid(User.Identity.Name, 6, cleanNumber, "singleAPI", "card"); if (!hasCredits) { var errorMessage = new List<CardValidationViewModel>(); errorMessage.Add(new CardValidationViewModel { IsValid = "No Credits Left" }); return Ok(errorMessage); } var cardType = new CardType(); var result = cardType.CardLogic(cleanNumber); return Ok(result); }
public IHttpActionResult Get(string id) { var iban = new data_validation.net.Web.Controllers.Helpers.RemoveSpecialCharacters(); var cleanIban = iban.RemoveSpecialCharactersBasic(id); var userIp = Request.GetOwinContext().Request.RemoteIpAddress; var userHost = Request.GetOwinContext().Request.Host.Value.ToString(); var isFraud = new IsFraudController(); var isFraudUser = isFraud.Check(User.Identity.Name, userIp, userHost); if (isFraudUser) { var errorMessage = new List<iBanBicModel>(); errorMessage.Add(new iBanBicModel { IsValid = "Fraud Triger On!" }); return Ok(errorMessage); } var helper = new data_validation.net.Web.Controllers.Helpers.CreditsDeduct(); var hasCredits = helper.IsValid(User.Identity.Name, 6, cleanIban, "singleAPI", "iban"); if (!hasCredits) { var errorMessage = new List<iBanBicModel>(); errorMessage.Add(new iBanBicModel { IsValid = "No Credits Left" }); return Ok(errorMessage); } var resT = new BankValidationController(); var temp = BankValidationController.Iban.CheckIban(id, true); var error = new List<iBanBicModel>(); if (!temp.IsValid) { error.Add(new iBanBicModel { IsValid = temp.Message, BankCode = cleanIban }); return Ok(error); } var result = resT.BicCountry(cleanIban.ToUpper()); return Ok(result); }
public IHttpActionResult Get(string id) { var phone = new data_validation.net.Web.Controllers.Helpers.RemoveSpecialCharacters(); var cleanPhone = phone.RemoveCharactersTelephone(id); var userIp = Request.GetOwinContext().Request.RemoteIpAddress; var userHost = Request.GetOwinContext().Request.Host.Value.ToString(); var isFraud = new IsFraudController(); var isFraudUser = isFraud.Check(User.Identity.Name, userIp, userHost); if (isFraudUser) { var errorMessage = new List<PhoneValidationViewModel>(); errorMessage.Add(new PhoneValidationViewModel { IsValid = "Fraud Triger On!" }); return Ok(errorMessage); } var helper = new data_validation.net.Web.Controllers.Helpers.CreditsDeduct(); var hasCredits = helper.IsValid(User.Identity.Name, 6, cleanPhone, "singleAPI", "telephone"); if (!hasCredits) { var errorMessage = new List<PhoneValidationViewModel>(); errorMessage.Add(new PhoneValidationViewModel { IsValid = "No Credits Left" }); return Ok(errorMessage); } var result = new List<PhoneValidationViewModel>(); if (cleanPhone.Length != 11 && cleanPhone.Length != 10) { result.Add(new PhoneValidationViewModel { IsValid = "Phone is invalid", Number = cleanPhone }); return Ok(result); } using (var context = new ApplicationDbContext()) { var tmpData = context.Database.SqlQuery<GetPhoneArea_Result>("GetPhoneArea2 @code", new SqlParameter("code", cleanPhone)).First(); if (tmpData.IsValid == "Valid") { result.Add(new PhoneValidationViewModel { Area = tmpData.AreaCovered, Number = cleanPhone, IsValid = tmpData.IsValid }); return Ok(result); } } result.Add(new PhoneValidationViewModel { Number = cleanPhone, IsValid = "Phone seems invalid" }); return Ok(result); }
public JsonResult TelephoneValidation(string id, string id2) { var apiNumber = id2; if (User.Identity.IsAuthenticated) { var helper = new Helpers.CreditsDeduct(); var res = helper.IsValid(User.Identity.Name, 6, id, "single", "email"); if (res == false) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return Json(404, JsonRequestBehavior.AllowGet); } } else { var isValid = new IsValid(); bool tUser = isValid.ValidUser(apiNumber, id, "email"); if (tUser == false) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return Json(410, JsonRequestBehavior.AllowGet); } } var removeSpecialCharacters = new RemoveSpecialCharacters(); var number = removeSpecialCharacters.RemoveCharactersTelephone(id); var result = new List<PhoneValidationViewModel>(); if (number.Length != 11 && number.Length != 10) { result.Add(new PhoneValidationViewModel { IsValid = "Phone is invalid", Number = id }); return Json(result, JsonRequestBehavior.AllowGet); } using (var context = new ApplicationDbContext()) { for (int i = 5; i >= 2; i--) { var tmpData = context.Database.SqlQuery<GetPhoneArea_Result>("GetPhoneArea2 @code", new SqlParameter("code", number.Substring(0, i))).First(); if (tmpData.IsValid == "Valid") { result.Add(new PhoneValidationViewModel { Area = tmpData.AreaCovered, Number = id, IsValid = tmpData.IsValid }); return Json(result, JsonRequestBehavior.AllowGet); } } } result.Add(new PhoneValidationViewModel { IsValid = "Phone seems invalid" }); return Json(result, JsonRequestBehavior.AllowGet); }
private List<PhoneValidationViewModel> Validate(DataTable csvData) { var results = new List<PhoneValidationViewModel>(); int invalidRecords = 0; int validRecords = 0; var removeSpecialCharacters = new RemoveSpecialCharacters(); foreach (DataRow res in csvData.Rows) { foreach (var number in res.ItemArray) { var cleanNumber = removeSpecialCharacters.RemoveCharactersTelephone(number.ToString()); if (cleanNumber.Length != 11 && cleanNumber.Length != 10) { results.Add(new PhoneValidationViewModel { IsValid = "Phone is invalid", Number = "=\"" + number.ToString() + "\"", }); invalidRecords++; } else { using (var context = new ApplicationDbContext()) { var tmpData = context.Database.SqlQuery<GetPhoneArea_Result>("GetPhoneArea2 @code", new SqlParameter("code", cleanNumber.Substring(0, 5))).First(); if (tmpData.IsValid == "Valid") { results.Add(new PhoneValidationViewModel { Area = tmpData.AreaCovered, Number = "=\"" + number.ToString() + "\"", IsValid = tmpData.IsValid }); validRecords++; break; } else { results.Add(new PhoneValidationViewModel { Area = tmpData.AreaCovered, Number = "=\"" + number.ToString() + "\"", IsValid = tmpData.IsValid }); invalidRecords++; break; } } } } } results.Add(new PhoneValidationViewModel { Number = invalidRecords.ToString(), Message = validRecords.ToString() }); return results; }