public Reception_Register CreateNewReceptionRegister(int?personId, string reasonForVisit, int?receptionVisitTypeId, DateTime?visitDate, int?receptionActionTakenId, DateTime dateCreated, string createdBy, bool isActive, bool isDeleted) { Reception_Register newReceptionRegister; using (var dbContext = new SDIIS_DatabaseEntities()) { var receptionRegister = new Reception_Register() { Person_Id = personId, Reason_For_Visit = reasonForVisit, Reception_Visit_Type_Id = receptionVisitTypeId, Visit_Date = visitDate, Reception_Action_Taken_Id = receptionActionTakenId, Date_Created = dateCreated, Created_By = createdBy, Is_Active = isActive, Is_Deleted = isDeleted }; try { newReceptionRegister = dbContext.Reception_Registers.Add(receptionRegister); dbContext.SaveChanges(); } catch (Exception) { return(null); } } return(newReceptionRegister); }
public Incident_Correspondence EditIncidentCorrespondence(int incidentCorrespondenceId, int incidentId, int correspondenceTypeId, DateTime dateCorrespondenceSent) { var dbContext = new SDIIS_DatabaseEntities(); try { var editincidentCorrespondence = (from a in dbContext.Incident_Correspondence_Items where a.Incident_Correspondence_Id.Equals(incidentCorrespondenceId) select a).FirstOrDefault(); if (editincidentCorrespondence == null) { return(null); } editincidentCorrespondence.Incident_Id = incidentId; editincidentCorrespondence.Correspondence_Type_Id = correspondenceTypeId; editincidentCorrespondence.Date_Correspondence_Sent = dateCorrespondenceSent; dbContext.SaveChanges(); return(editincidentCorrespondence); } catch (Exception) { return(null); } }
public NISIS_Profiling_Instance_Referral UpdateProfilingInstanceReferral(int profilingInstanceReferralId, int serviceStatusId) { NISIS_Profiling_Instance_Referral editReferral; var dbContext = new SDIIS_DatabaseEntities(); try { editReferral = (from e in dbContext.NISIS_Profiling_Instance_Referrals where e.NISIS_Household_Referral_Id.Equals(profilingInstanceReferralId) select e).FirstOrDefault(); if (editReferral == null) { return(null); } editReferral.Service_Status_Id = serviceStatusId; dbContext.SaveChanges(); } catch (Exception) { return(null); } return(editReferral); }
public Organization CreateOrganization(string description, string telephoneNumber, string faxNumber, string emailAddress, bool isActive, bool isDeleted, DateTime dateCreated, string createdBy) { var dbContext = new SDIIS_DatabaseEntities(); var organization = new Organization() { Description = description, Telephone_Number = telephoneNumber, Fax_Number = faxNumber, Email_Address = emailAddress, Is_Active = isActive, Is_Deleted = isDeleted, Date_Created = dateCreated, Created_By = createdBy }; try { var newOrganization = dbContext.Organizations.Add(organization); dbContext.SaveChanges(); return(newOrganization); } catch (Exception) { return(null); } }
public Organization SetOrganizationIsDeleted(int organizationId, bool isDeleted) { Organization editOrganization; using (var dbContext = new SDIIS_DatabaseEntities()) { try { editOrganization = (from e in dbContext.Organizations where e.Organization_Id.Equals(organizationId) select e).FirstOrDefault(); if (editOrganization == null) { return(null); } editOrganization.Is_Deleted = isDeleted; dbContext.SaveChanges(); } catch (Exception) { return(null); } } return(editOrganization); }
public Address EditAddress(int addressId, int addressTypeId, string addressLine1, string addressLine2, int?townId, string postalCode) { Address editAddress; using (var dbContext = new SDIIS_DatabaseEntities()) { editAddress = (from a in dbContext.Addresses where a.Address_Id.Equals(addressId) select a).FirstOrDefault(); if (editAddress == null) { return(null); } editAddress.Address_Type_Id = addressTypeId; editAddress.Address_Line_1 = addressLine1; editAddress.Address_Line_2 = addressLine2; editAddress.Town_Id = townId; editAddress.Postal_Code = postalCode; dbContext.SaveChanges(); } return(editAddress); }
public CYCA_Dynamic_Form_Data AddOrUpdateDynamicFormDatas(CYCA_Dynamic_Form_Data data) { CYCA_Dynamic_Form_Data record = dbContext.CYCA_Dynamic_Form_Data.Where(d => d.Dynamic_Form_Data_Id == data.Dynamic_Form_Data_Id).SingleOrDefault(); if (record == null) { record = new CYCA_Dynamic_Form_Data() { Client_Id = data.Client_Id, CreatedDate = data.CreatedDate, Data = data.Data, Dynamic_Form_Id = data.Dynamic_Form_Id, User_Id = data.User_Id, Venue_Id = data.Venue_Id }; dbContext.CYCA_Dynamic_Form_Data.Add(record); //dbContext.SaveChanges(); data.Dynamic_Form_Data_Id = record.Dynamic_Form_Data_Id; } else { record.Data = data.Data; } dbContext.SaveChanges(); return(data); }
public Questionnaire_Section SetQuestionnaireSectionIsActive(int sectionId, bool isActive) { Questionnaire_Section editSection; using (var dbContext = new SDIIS_DatabaseEntities()) { try { editSection = (from x in dbContext.Questionnaire_Sections where x.Questionnaire_Section_Id.Equals(sectionId) select x).FirstOrDefault(); if (editSection == null) { return(null); } editSection.Is_Active = isActive; dbContext.SaveChanges(); } catch (Exception) { return(null); } } return(editSection); }
public Intake_Assessment AcceptVEPCase(int intakeAssessmentId) { Intake_Assessment editIntakeAssessment; var dbContext = new SDIIS_DatabaseEntities(); try { editIntakeAssessment = dbContext.Intake_Assessments.SingleOrDefault(a => a.Intake_Assessment_Id == intakeAssessmentId); if (editIntakeAssessment == null) { return(null); } editIntakeAssessment.Treatment_Date = DateTime.Now; dbContext.SaveChanges(); } catch (Exception) { return(null); } return(editIntakeAssessment); }
public VEP_Referals EditReferralDetails(int referralId, string referralNotes, int?referralTypeId) { VEP_Referals editReferralDetails; using (var dbContext = new SDIIS_DatabaseEntities()) { try { editReferralDetails = (from p in dbContext.VEP_Referals where p.ReferalsId.Equals(referralId) select p).FirstOrDefault(); if (editReferralDetails == null) { return(null); } editReferralDetails.ReferalsId = referralId; editReferralDetails.Notes = referralNotes.Trim(); editReferralDetails.ToDepartment = referralTypeId.Value; dbContext.SaveChanges(); } catch (Exception) { return(null); } } return(editReferralDetails); }
public Service_Office CreateServiceOffice(string Description, string Municipality, string UserName) { var dbContext = new SDIIS_DatabaseEntities(); int munId = (from a in dbContext.Local_Municipalities where a.Description == Municipality select a.Local_Municipality_Id).FirstOrDefault(); var service_Office = new Service_Office() { Description = Description, Local_Municipality_Id = munId, Is_Active = true, Is_Deleted = false, Date_Created = DateTime.Now, Created_By = UserName }; try { var newService_Office = dbContext.Service_Offices.Add(service_Office); dbContext.SaveChanges(); return(newService_Office); } catch (Exception) { return(null); } }
public VEP_Referals CreateReferrals(VEP_Referals model) { var dbContext = new SDIIS_DatabaseEntities(); try { VEP_Referals referalTable = new VEP_Referals(); referalTable.CaseId = model.CaseId; referalTable.FromDepartment = 1; referalTable.ToDepartment = Convert.ToInt32(model.ToDepartment); referalTable.Notes = model.Notes; referalTable.Createdby = model.Createdby; referalTable.CreateDate = DateTime.Now; dbContext.VEP_Referals.Add(referalTable); dbContext.SaveChanges(); return(model); } catch (Exception ex) { var Test = ex.Message; return(null); } }
public Questionnaire EditQuestionnaire(int questionnaireId, int profilingToolId, string description, bool isActive, bool isDeleted, DateTime?dateLastModified, string modifiedBy) { var dbContext = new SDIIS_DatabaseEntities(); try { var editQuestionnaire = (from x in dbContext.Questionnaires where x.Questionnaire_Id.Equals(questionnaireId) select x).FirstOrDefault(); if (editQuestionnaire == null) { return(null); } editQuestionnaire.Profiling_Tool_Id = profilingToolId; editQuestionnaire.Description = description; editQuestionnaire.Is_Active = isActive; editQuestionnaire.Is_Deleted = isDeleted; editQuestionnaire.Date_Last_Modified = dateLastModified; editQuestionnaire.Modified_By = modifiedBy; dbContext.SaveChanges(); return(editQuestionnaire); } catch (Exception) { return(null); } }
public Questionnaire CreateQuestionnaire(int profilingToolId, string description, bool isActive, bool isDeleted, DateTime dateCreated, string createdBy) { Questionnaire newQuestionnaire; var dbContext = new SDIIS_DatabaseEntities(); var questionnaire = new Questionnaire() { Profiling_Tool_Id = profilingToolId, Description = description, Is_Active = isActive, Is_Deleted = isDeleted, Date_Created = dateCreated, Created_By = createdBy }; try { newQuestionnaire = dbContext.Questionnaires.Add(questionnaire); dbContext.SaveChanges(); } catch (Exception ex) { return(null); } return(newQuestionnaire); }
public CPR_Incident AssignReferenceNumber(int incidentId, string referenceNumber) { var dbContext = new SDIIS_DatabaseEntities(); try { var editIncident = (from i in dbContext.CPR_Incidents where i.Incident_Id.Equals(incidentId) select i).FirstOrDefault(); if (editIncident == null) { return(null); } editIncident.Reference_Number = referenceNumber; dbContext.SaveChanges(); return(editIncident); } catch (Exception ex) { return(null); } }
public Intake_Assessment AssignCaseManager(int intakeAssessmentId, int caseManagerId) { Intake_Assessment editIntakeAssessment; var dbContext = new SDIIS_DatabaseEntities(); try { editIntakeAssessment = (from e in dbContext.Intake_Assessments where e.Intake_Assessment_Id.Equals(intakeAssessmentId) select e).FirstOrDefault(); if (editIntakeAssessment == null) { return(null); } editIntakeAssessment.Case_Manager_Id = caseManagerId; dbContext.SaveChanges(); } catch (Exception) { return(null); } return(editIntakeAssessment); }
public CPR_Incident AddAbuseIndicatorsToIncident(int incidentId, List <int> abuseIndicatorIds) { var dbContext = new SDIIS_DatabaseEntities(); try { var incidentToEdit = dbContext.CPR_Incidents.FirstOrDefault(x => x.Incident_Id.Equals(incidentId)); if (incidentToEdit == null) { return(null); } incidentToEdit.Abuse_Indicators.Clear(); foreach (var abuseIndicatorId in abuseIndicatorIds) { var indicatorToAdd = dbContext.Abuse_Indicators.FirstOrDefault(x => x.Abuse_Indicator_Id.Equals(abuseIndicatorId)); if (indicatorToAdd == null) { return(null); } incidentToEdit.Abuse_Indicators.Add(indicatorToAdd); } dbContext.SaveChanges(); return(incidentToEdit); } catch (Exception ex) { return(null); } }
public Intake_Assessment AddReferralFocusAreaToIntakeAssessment(int intakeAssessmentId, List <int> referralFocusAreaIds) { var dbContext = new SDIIS_DatabaseEntities(); try { var intakeAssessmentToEdit = dbContext.Intake_Assessments.FirstOrDefault(x => x.Intake_Assessment_Id.Equals(intakeAssessmentId)); if (intakeAssessmentToEdit == null) { return(null); } intakeAssessmentToEdit.Referral_Focus_Areas.Clear(); foreach (var roleId in referralFocusAreaIds) { var focusAreaToAdd = dbContext.Referral_Focus_Areas.FirstOrDefault(x => x.Referral_Focus_Area_Id.Equals(roleId)); if (focusAreaToAdd == null) { return(null); } intakeAssessmentToEdit.Referral_Focus_Areas.Add(focusAreaToAdd); } dbContext.SaveChanges(); return(intakeAssessmentToEdit); } catch (Exception ex) { return(null); } }
public Client_Foster_Parent EditClientFosterParent(int itemId, int personId, bool?isDeceased, DateTime?dateDeceased, DateTime dateLastModified, string modifiedBy, bool isActive, bool isDeleted) { Client_Foster_Parent editFosterParent; using (var dbContext = new SDIIS_DatabaseEntities()) { try { editFosterParent = (from a in dbContext.Client_Foster_Parents where a.Client_Foster_Parent_Id.Equals(itemId) select a).FirstOrDefault(); if (editFosterParent == null) { return(null); } editFosterParent.Person_Id = personId; editFosterParent.Is_Deceased = isDeceased; editFosterParent.Date_Deceased = dateDeceased; editFosterParent.Is_Active = isActive; editFosterParent.Is_Deleted = isDeleted; editFosterParent.Date_Last_Modified = dateLastModified; editFosterParent.Modified_By = modifiedBy; dbContext.SaveChanges(); } catch (Exception) { return(null); } } return(editFosterParent); }
public void UpdateReferalToCouncelling(PCMReferralsViewModel vm, int userId, int Referrals_Councelling_Id) { using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities()) { try { PCM_Referral_Counselling ass = db.PCM_Referral_Counselling.Find(Referrals_Councelling_Id); //cases.PCM_Case_Id = cas ass.Referrals_Id = vm.Referrals_Id; ass.Type_Referral_Id = vm.Type_Referral_Id; ass.Referral_of_Child_To_Counselling = vm.Referral_of_Child_To_Counselling; ass.Period_From = vm.Period_From; ass.Period = vm.Period_To; ass.Child_Progress = vm.Progress_Report; ass.Modified_By = userId; ass.Date_Modified = DateTime.Now; db.SaveChanges(); } catch { } } }
public CPR_First_Reporter EditCPRFirstReporter(int cprFirstReporterId, int incidentId, int personId, int?districtId, int?childRelationTypeId) { CPR_First_Reporter editCPRFirstReporter; using (var dbContext = new SDIIS_DatabaseEntities()) { try { editCPRFirstReporter = (from a in dbContext.CPR_First_Reporters where a.CPR_First_Reporter_Id.Equals(cprFirstReporterId) select a).FirstOrDefault(); if (editCPRFirstReporter == null) { return(null); } editCPRFirstReporter.Incident_Id = incidentId; editCPRFirstReporter.Person_Id = personId; editCPRFirstReporter.District_Id = districtId; editCPRFirstReporter.Child_Relationship_Type_Id = childRelationTypeId; dbContext.SaveChanges(); } catch (Exception) { return(null); } } return(editCPRFirstReporter); }
public void UpdateReferalToSocialWorker(PCMReferralsViewModel vm, int userId, int Referrals_SocilaWorker_Id) { using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities()) { try { PCM_Referral_SocilaWorker ass = db.PCM_Referral_SocilaWorker.Find(Referrals_SocilaWorker_Id); //cases.PCM_Case_Id = cas ass.Referrals_Id = vm.Referrals_Id; ass.Type_Referral_Id = vm.Type_Referral_Id; ass.Referral_Child_To_Social_Worker = vm.Referral_Child_To_Social_Worker; ass.Programme_Period_From = vm.Period_From; ass.Programme_Period = vm.Period_To; ass.Child_Progress = vm.Progress_Report; ass.Modified_By = userId; ass.Date_Modified = DateTime.Now; db.SaveChanges(); } catch { } } }
public Organization EditOrganization(int organizationId, string description, string telephoneNumber, string faxNumber, string emailAddress, bool isActive, bool isDeleted, DateTime dateLastModified, string modifiedBy) { var dbContext = new SDIIS_DatabaseEntities(); try { var editOrganization = (from mc in dbContext.Organizations where mc.Organization_Id.Equals(organizationId) select mc).FirstOrDefault(); if (editOrganization == null) { return(null); } editOrganization.Description = description; editOrganization.Telephone_Number = telephoneNumber; editOrganization.Fax_Number = faxNumber; editOrganization.Email_Address = emailAddress; editOrganization.Is_Active = isActive; editOrganization.Is_Deleted = isDeleted; editOrganization.Date_Last_Modified = dateLastModified; editOrganization.Modified_By = modifiedBy; dbContext.SaveChanges(); return(editOrganization); } catch (Exception) { return(null); } }
public Person UpdateNISISData(int personId, string firstName, string lastName, string idNumber, int?maritalStatusId) { Person editPerson; using (var dbContext = new SDIIS_DatabaseEntities()) { try { editPerson = (from p in dbContext.Persons where p.Person_Id.Equals(personId) select p).FirstOrDefault(); if (editPerson == null) { return(null); } editPerson.First_Name = firstName; editPerson.Last_Name = lastName; editPerson.Identification_Number = idNumber; editPerson.Marital_Status_Id = maritalStatusId; dbContext.SaveChanges(); } catch (Exception ex) { return(null); } } return(editPerson); }
public Questionnaire_Question SetQuestionnaireQuestionIsDeleted(int questionId, bool isDeleted) { Questionnaire_Question editQuestion; using (var dbContext = new SDIIS_DatabaseEntities()) { try { editQuestion = (from x in dbContext.Questionnaire_Questions where x.Questionnaire_Question_Id.Equals(questionId) select x).FirstOrDefault(); if (editQuestion == null) { return(null); } editQuestion.Is_Deleted = isDeleted; dbContext.SaveChanges(); } catch (Exception) { return(null); } } return(editQuestion); }
public Community_Profiling_Instance CreateCommunityProfilingInstance(DateTime profilingDate, int profilingToolId, int capturedByUserId, int siteEAId, string createdBy, DateTime createdDate, bool isActive, bool isDeleted) { Community_Profiling_Instance newCommunityProfilingInstance; var dbContext = new SDIIS_DatabaseEntities(); var communityProfilingInstance = new Community_Profiling_Instance() { Profiling_Date = profilingDate, Profiling_Tool_Id = profilingToolId, Captured_By_UserId = capturedByUserId, NISIS_Site_EA_Id = siteEAId, QA_Status_Item_Id = (int)QAStatusEnum.NotSet, Created_By = createdBy, Date_Created = createdDate, Is_Active = isActive, Is_Deleted = isDeleted }; try { newCommunityProfilingInstance = dbContext.Community_Profiling_Instances.Add(communityProfilingInstance); dbContext.SaveChanges(); } catch (Exception ex) { var exMsg = ex.Message; return(null); } return(newCommunityProfilingInstance); }
public Incident_Correspondence CreateIncidentCorrespondence(int incidentId, int correspondenceTypeId, DateTime dateCorrespondenceSent) { Incident_Correspondence newIncidentCorrespondence; using (var dbContext = new SDIIS_DatabaseEntities()) { var incidentCorrespondence = new Incident_Correspondence() { Incident_Id = incidentId, Correspondence_Type_Id = correspondenceTypeId, Date_Correspondence_Sent = dateCorrespondenceSent }; try { newIncidentCorrespondence = dbContext.Incident_Correspondence_Items.Add(incidentCorrespondence); dbContext.SaveChanges(); } catch (Exception ex) { string exVal = ex.Message; return(null); } } return(newIncidentCorrespondence); }
public Community_Profiling_Instance SetCommunityProfilingInstanceQAStatus(int communityProfilingInstanceId, int qaStatusId) { Community_Profiling_Instance editCommunityProfilingInstance; var dbContext = new SDIIS_DatabaseEntities(); try { editCommunityProfilingInstance = (from x in dbContext.Community_Profiling_Instances where x.Community_Profiling_Instance_Id.Equals(communityProfilingInstanceId) select x).FirstOrDefault(); if (editCommunityProfilingInstance == null) { return(null); } editCommunityProfilingInstance.QA_Status_Item_Id = qaStatusId; dbContext.SaveChanges(); } catch (Exception) { return(null); } return(editCommunityProfilingInstance); }
public int Create(int selected_SpecialNeedId, int personId) { var dbContext = new SDIIS_DatabaseEntities(); try { var personSpecialNeedRecord = new Int_Person_SpecialNeed(); personSpecialNeedRecord.Person_Id = personId; personSpecialNeedRecord.SpecialNeed_Id = selected_SpecialNeedId; dbContext.Int_Person_SpecialNeed.Add(personSpecialNeedRecord); dbContext.SaveChanges(); return(personSpecialNeedRecord.Person_SpecialNeed_Id); } //catch (Exception ex) //{ // return -1; //} catch (DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { //Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); var msg = validationError.PropertyName + " Error: " + validationError.ErrorMessage; } } } return(-1); }
public CPR_Conviction CreateCPRConviction(int allegedOffenderId, string j14ReferenceNumber, string sapsCaseNumber, int?courtId, string conviction, string natureOfCharge, string sentence, DateTime?dateSentenced, string accountOfCharge) { CPR_Conviction newConviction; using (var dbContext = new SDIIS_DatabaseEntities()) { var cprConviction = new CPR_Conviction() { Alleged_Offender_Id = allegedOffenderId, J14_Reference_Number = j14ReferenceNumber, SAPS_Case_Number = sapsCaseNumber, Court_Id = courtId, Conviction = conviction, Nature_Of_Charge = natureOfCharge, Sentence = sentence, Date_Sentenced = dateSentenced, Account_Of_Charge_And_Conviction = accountOfCharge }; try { newConviction = dbContext.CPR_Convictions.Add(cprConviction); dbContext.SaveChanges(); } catch (Exception ex) { string exVal = ex.Message; return(null); } } return(newConviction); }