/// <summary> /// Updates / Inserts new Clinincian /// </summary> /// <param name="clinician"></param> /// <returns></returns> public int UpsertClinician(tblClinician clinician) { if (clinician.ClinicianID == 0) //new record { try { dc.tblClinicians.InsertOnSubmit(clinician); dc.SubmitChanges(); var Id = clinician.ClinicianID; clinician.UserID = GenerateUserID(Id, UserType.Clinician); UpsertClinician(clinician); //2nd call updates the UserID return(Id); } catch (Exception ex) { throw ex; } } else { try { var record = dc.tblClinicians.FirstOrDefault(x => x.ClinicianID == clinician.ClinicianID); record = clinician; dc.SubmitChanges(); return(record.ClinicianID); } catch (Exception ex) { throw ex; } } }
///// <summary> ///// Returns a list of PopulationTypes for a given job ///// </summary> ///// <param name="jobID"></param> ///// <returns></returns> //public List<tblJobPatientPopulationType> GetJobPatientPopulationTypes(int jobID) //{ // return dc.tblJobPatientPopulationTypes.Where(x => x.JobID == jobID).ToList(); //} ///// <summary> ///// Returns a list of Job Exp types for a given job ///// </summary> ///// <param name="jobID"></param> ///// <returns></returns> //public List<tblJobJobExperienceType> GetJobJobExperienceTypes(int jobID) //{ // return dc.tblJobJobExperienceTypes.Where(x => x.JobID == jobID).ToList(); //} #endregion *** General Fields *** #region *** Inserts *** public bool UpSertClinician(tblClinician clinician) { if (clinician.ClinicianID == 0) //new record { try { dc.tblClinicians.InsertOnSubmit(clinician); dc.SubmitChanges(); return(true); } catch (Exception ex) { return(false); } } else { try { var record = dc.tblClinicians.FirstOrDefault(x => x.ClinicianID == clinician.ClinicianID); record = clinician; dc.SubmitChanges(); return(true); } catch (Exception ex) { return(false); } } }