public bool ValidateCustomerPostId(string id) { bool exists = false; if (!string.IsNullOrEmpty(id)) { id = id.ToUpper(); using (var newCont = new DPACEntities()) { var execGetCustomerName = newCont.GetCustomerName(id).FirstOrDefault(); if (execGetCustomerName == null) { return(false); } exists = (execGetCustomerName.fbonumbr != null) ? true : false; } } return(exists); }
public JsonResult CheckForCustomerInDpac(string id) { //call the stored procedure that will look for the id in dpac if (String.IsNullOrEmpty(id)) { return(Json(new { success = false, message = $"string value is empty or null" }, JsonRequestBehavior.AllowGet)); } if (id.Length > 10) { return(Json(new { success = false, message = $"string {id} length has exceeded the DPAC customer Id threshold" }, JsonRequestBehavior.AllowGet)); } else { string idMod = id.ToUpper();//capitalize characters using (var newCont = new DPACEntities()) { var execGetCustomerName = newCont.GetCustomerName(idMod).FirstOrDefault(); if (execGetCustomerName == null) { return(Json(new { success = false, message = $"{idMod} could not be located in DPAC" }, JsonRequestBehavior.AllowGet)); } if (execGetCustomerName.fbonumbr != null) { return(Json(new { success = true, fullname = execGetCustomerName.fbobname, bday = execGetCustomerName.birthdate.ToString() }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = $"Unfortunately, the id: {id} could not be located in DPAC" }, JsonRequestBehavior.AllowGet)); } } //return Json(new { success = true, message = $"string: {id} In terms of length, looks okay" }, JsonRequestBehavior.AllowGet); } }