public List <ViewCasePool> DoctorCaseData(int uid) { try { List <ViewCasePool> CpList = new List <ViewCasePool>(); EF_Database ctx = new EF_Database(); int did = (from i in ctx.Doctors where i.UserId == uid select i.DOCTOR_ID).FirstOrDefault(); var res = from i in ctx.CasePools where i.DoctorId == did select i; foreach (var obj in res) { ViewCasePool vcp = new ViewCasePool(); vcp.CaseId = obj.CASE_ID; vcp.AccepterId = obj.AccepterId.HasValue ? obj.AccepterId.Value.ToString() : "NA"; vcp.DoctorId = obj.DoctorId.HasValue ? obj.DoctorId.Value.ToString() : "NA"; //ternary Operator vcp.DonorId = obj.DonorId; //modified Code /*.HasValue ? obj.DonorId.Value.ToString() : "NA";*/ vcp.Organs = obj.ORGANS != null ? obj.ORGANS : "NA"; vcp.Status = obj.STATUS; CpList.Add(vcp); } return(CpList); } catch (Exception e) { throw new Exception("Error"); } }
public List <ViewCasePool> RetriveCaseData() { try { List <ViewCasePool> CpList = new List <ViewCasePool>(); EF_Database ctx = new EF_Database(); var res = from i in ctx.CasePools select i; foreach (var obj in res) { ViewCasePool vcp = new ViewCasePool(); vcp.CaseId = obj.CASE_ID; vcp.AccepterId = obj.AccepterId.HasValue ? obj.AccepterId.Value.ToString() : "NA"; vcp.DoctorId = obj.DoctorId.HasValue ? obj.DoctorId.Value.ToString() : "NA"; //ternary Operator vcp.DonorId = obj.DonorId; //modified Code /*.HasValue ? obj.DonorId.Value.ToString() : "NA";*/ vcp.Organs = obj.ORGANS != null ? obj.ORGANS : "NA"; vcp.Status = obj.STATUS; CpList.Add(vcp); } return(CpList); } catch (Exception e) { throw new Exception("Error"); } }