public JsonResult GetPCMCourtReferralsById(int Court_Referrals_Id) { using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities()) { db.Configuration.LazyLoadingEnabled = false; PCM_Referral_To_Court model = db.PCM_Referral_To_Court.Where(x => x.Court_Referrals_Id == Court_Referrals_Id).SingleOrDefault(); string value = string.Empty; value = JsonConvert.SerializeObject(model, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); return(Json(value, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetPCMReferraltypeById(int Referrals_Id, int Type_Referral_Id) { //get current username string loginName = User.Identity.Name; Session["LoginName"] = loginName; var currentUser = (User)Session["CurrentUser"]; var userProvince = -1; var userId = 0; if (currentUser != null) { userId = currentUser.User_Id; if (currentUser.Employees.Any()) { userProvince = currentUser.Employees.First().apl_Service_Office.apl_Local_Municipality.District.Province_Id; } if (currentUser.apl_Social_Worker.Any()) { userProvince = currentUser.apl_Social_Worker.First().apl_Service_Office.apl_Local_Municipality.District.Province_Id; } } using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities()) { db.Configuration.LazyLoadingEnabled = false; string value = string.Empty; if (Referrals_Id != 0 && Type_Referral_Id == 1) { PCM_Referral_To_Court model1 = db.PCM_Referral_To_Court.Where(x => x.Referrals_Id == Referrals_Id).SingleOrDefault(); value = JsonConvert.SerializeObject(model1, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); Session["Referrals_Id"] = Referrals_Id; } else if (Referrals_Id != 0 && Type_Referral_Id == 2) { PCM_Referral_To_Programme model1 = db.PCM_Referral_To_Programme.Where(x => x.Referrals_Id == Referrals_Id).SingleOrDefault(); value = JsonConvert.SerializeObject(model1, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); Session["Referrals_Id"] = Referrals_Id; } else if (Referrals_Id != 0 && Type_Referral_Id == 3) { PCM_Referral_Counselling model1 = db.PCM_Referral_Counselling.Where(x => x.Referrals_Id == Referrals_Id).SingleOrDefault(); value = JsonConvert.SerializeObject(model1, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); Session["Referrals_Id"] = Referrals_Id; } else if (Referrals_Id != 0 && Type_Referral_Id == 4) { PCM_Referral_SocilaWorker model1 = db.PCM_Referral_SocilaWorker.Where(x => x.Referrals_Id == Referrals_Id).SingleOrDefault(); value = JsonConvert.SerializeObject(model1, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); Session["Referrals_Id"] = Referrals_Id; } string valueFinal = string.Empty; valueFinal = value; return(Json(value, JsonRequestBehavior.AllowGet)); } }