public JsonResult AddUpdatePharmacy(PatientPharmacy_Custom pharmacy) { ApiResultModel apiresult = new ApiResultModel(); try { if (pharmacy.pharmacy == null || pharmacy.pharmacy == "" || !Regex.IsMatch(pharmacy.pharmacy, "^[0-9a-zA-Z ]+$")) { apiresult.message = "Invalid pharmacy name.Only letters and numbers are allowed."; return(Json(new { Success = true, ApiResultModel = apiresult })); } else { PatientRepository objRepo = new PatientRepository(); apiresult = objRepo.AddPharmacy(pharmacy); return(Json(new { Success = true, ApiResultModel = apiresult })); } } catch (Exception ex) { return(Json(new { Message = ex.Message })); } }