public IHttpActionResult Getspecialty([FromUri] get_specialty param) { string msg = ""; if (true)//progAuth.authorize() { List <doc_specialty_01112018> spec = specialty(param); var ret1 = JsonConvert.SerializeObject(spec); var json = Newtonsoft.Json.Linq.JArray.Parse(ret1); // get appointment_type_id return(Json(new { specialty = json, message = msg, success = true })); //var ret = JsonConvert.SerializeObject(doctorSpec); //var json = Newtonsoft.Json.Linq.JArray.Parse(ret); msg = "Specialty for the doctor is added."; return(Json(new { data = new string[] { }, message = msg, success = true })); } else { msg = "The authorization header is either not valid or isn't Basic."; return(Json(new { data = new string[] { }, message = msg, success = false })); //throw new Exception("The authorization header is either not valid or isn't Basic."); } }
private List <doc_specialty_01112018> specialty(get_specialty param) { // created: 01/11/2018 List <doc_specialty_01112018> spec = new List <doc_specialty_01112018>(); // 1/16/2018 var ref_specialty = from a in dbEntity.ref_specialty1 // //join b in dbEntity.ref_condition on a. // select a; var ref_specialty = from a in dbEntity.con_ref_specialty_ref_condition select new { level2_classification = a.ref_specialty1.level2_classification, level3_specialization = a.ref_specialty1.level3_specialization, condition = a.ref_condition }; if (!string.IsNullOrEmpty(param.startwith)) { ref_specialty = ref_specialty.Where(a => a.level3_specialization.StartsWith(param.startwith) || a.level2_classification.StartsWith(param.startwith) ); } foreach (var i in ref_specialty) { //List<string> condition = new List<string>(); ////if (i.conditions != null) { //// string[] con = i.conditions.Split('|'); // foreach (var c in i.condition) // { condition.Add(c.description); } ////} //spec.Add(new doc_specialty_01112018 //{ // id = i.id, // provider_type = i.ref_specialty_provider.name,// s.provider_type, // classification_code = i.level2_classification_code == null ? "" : i.level2_classification_code, // classification = i.level2_classification, // specialization_code = i.level3_specialization_code == null ? "" : i.level3_specialization_code, // specialization = i.level3_specialization == null ? "" : i.level3_specialization, // s.specialization, // conditions = condition //}); } return(spec); }