public async Task <Result <AddPersonRelationshipResponse> > Handle(AddPersonRelationshipCommand request, CancellationToken cancellationToken) { try { using (_unitOfWork) { PersonRelationship personRelationship = new PersonRelationship(); personRelationship.PersonId = request.PersonId; personRelationship.PatientId = request.PatientId; personRelationship.RelationshipTypeId = request.RelationshipTypeId; personRelationship.CreatedBy = request.UserId; personRelationship.CreateDate = DateTime.Now; await _unitOfWork.Repository <PersonRelationship>().AddAsync(personRelationship); await _unitOfWork.SaveAsync(); _unitOfWork.Dispose(); return(Result <AddPersonRelationshipResponse> .Valid(new AddPersonRelationshipResponse() { PersonRelationshipId = personRelationship.Id })); } } catch (Exception e) { return(Result <AddPersonRelationshipResponse> .Invalid(e.Message)); } }
public IList <PersonRelationship> GetPersonRelationships(Person p) { PersonRelationship rel = null; PersonRelationshipType t = null; var subquery = QueryOver.Of <PersonResponsibility>() .Where(x => x.Person != p) .And(x => !x.Archive) .Select(x => x.Person); return(Session.QueryOver <PersonRelationship>(() => rel) .JoinAlias(() => rel.PersonRelationshipType, () => t, JoinType.InnerJoin) .Where(() => !rel.Archive) .And(Restrictions.Disjunction() .Add(() => rel.SubjectPerson == p) .Add(() => rel.ObjectPerson == p) ) .AndRestrictionOn(() => t.Code).IsIn(new string[] { PersonRelationshipType.CODE_ACTED_TOGETHER_WITH, PersonRelationshipType.CODE_BELONGED_TO_THE_SAME_GROUP_AS, PersonRelationshipType.CODE_FOUGHT_IN_THE_SAME_GROUP_AS, PersonRelationshipType.CODE_FOUGHT_WITH, PersonRelationshipType.CODE_IS_A_SUBORDINATE_OF, PersonRelationshipType.CODE_IS_A_SUPERIOR_TO, PersonRelationshipType.CODE_IS_THE_BODYGUARD_OF, PersonRelationshipType.CODE_IS_THE_DEPUTY_OF, PersonRelationshipType.CODE_PROVIDED_WEAPONS_AND_AMMUNITION_TO }) .And(Restrictions.Disjunction() .Add(Subqueries.WhereProperty(() => rel.SubjectPerson).In(subquery)) .Add(Subqueries.WhereProperty(() => rel.ObjectPerson).In(subquery)) ) .List()); }
public PersonRelationshipDTO(PersonRelationship source) : base(source) { PersonRelationshipID = source.PersonRelationshipID; PersonID = source.PersonID; RelatedPersonID = source.RelatedPersonID; }
public JsonNetResult Edit(PersonRelationshipViewModel vm) { if (ModelState.IsValid) { PersonRelationship relationship = this.personTasks.GetPersonRelationship(vm.Id); if (relationship != null) { Mapper.Map <PersonRelationshipViewModel, PersonRelationship>(vm, relationship); relationship.SubjectPerson = this.personTasks.GetPerson(vm.SubjectPersonId.Value); relationship.ObjectPerson = this.personTasks.GetPerson(vm.ObjectPersonId.Value); relationship.PersonRelationshipType = this.personTasks.GetPersonRelationshipType(vm.PersonRelationshipTypeId.Value); relationship = this.personTasks.SavePersonRelationship(relationship); return(JsonNet(string.Empty)); } else { Response.StatusCode = (int)HttpStatusCode.NotFound; return(JsonNet("Person relationship not found.")); } } else { return(JsonNet(this.GetErrorsForJson())); } }
public async Task <PersonRelationship> addPersonRelationship(int personId, int patientId, int relationshipTypeId, int userId) { try { PersonRelationship personRelationship = new PersonRelationship() { PersonId = personId, PatientId = patientId, RelationshipTypeId = relationshipTypeId, DeleteFlag = false, CreatedBy = userId, CreateDate = DateTime.Now }; await _unitOfWork.Repository <PersonRelationship>().AddAsync(personRelationship); await _unitOfWork.SaveAsync(); return(personRelationship); } catch (Exception e) { throw e; } }
public async Task <ActionResult <List <PersonRelations> > > GetPersonRelations(string id) { var relations = await PersonRelationship.GetRelations(id); return(relations.Count > 0 ? Ok(relations) : NotFound("user relationship was not found")); }
public void AddRelatedIfPersonNotExists(int personId, Person relatedPerson, RelationshipType RelationshipType) { var personRelation = new PersonRelationship { PersonId = personId, RelatedPerson = relatedPerson, RelationshipType = RelationshipType }; context.PersonRelationships.Add(personRelation); }
public async Task <IActionResult> CreateRelation(SingleRelation relation) { var z = await PersonRelationship.CreateRelation(relation); return(z.ErrorCode == ErrorList.OK ? Ok("Relation created") : BadRequest(z.Description)); }
public PersonRelationshipDetailWindow (PersonRelationship pr, EventHandler OnSave, Gtk.Window parent) : base(Gtk.WindowType.Toplevel) { this.Build (); this.Modal = true; this.OnSaved = OnSave; this.TransientFor = parent; show.PersonRelationship = pr; show.IsEditable = false; }
public PersonRelationshipDetailWindow (PersonRelationship pr, Gtk.Window parent) : base(Gtk.WindowType.Toplevel) { this.Build (); this.Modal = true; this.TransientFor = parent; show.PersonRelationship = pr; show.IsEditable = true; show.HideActionButtons (); }
public int UpdatePersonRelationship(int relatedTo, int relationshipType) { PersonRelationship personRelatioship = new PersonRelationship() { //RelatedTo = relatedTo, RelationshipTypeId = relationshipType }; return(_result = _mgr.UpdatePersonRelationship(personRelatioship)); }
public async Task <ActionResult <List <PersonRelations> > > RelationReport(string id, string type) { var z = await PersonRelationship.RelationReportRep(id, type); return(z.Count > 0 ? Ok(z) : NotFound(new ErrorClass { ErrorCode = ErrorList.ERROR_NON_EXISTENT, Description = $"no relation was found error : {ErrorList.ERROR_NON_EXISTENT}" })); }
public PersonRelationshipViewModel(PersonRelationship pr) { Mapper.Map <PersonRelationship, PersonRelationshipViewModel>(pr, this); this.SubjectPersonId = pr.SubjectPerson.Id; this.ObjectPersonId = pr.ObjectPerson.Id; this.PersonRelationshipTypeId = pr.PersonRelationshipType.Id; this.SubjectPersonName = pr.SubjectPerson.Name; this.ObjectPersonName = pr.ObjectPerson.Name; this.PersonRelationshipTypeName = pr.PersonRelationshipType.ToString(); }
public int AddPersonRelationship(int personId, int relatedTo, int relationshipType) { PersonRelationship personRelatioship = new PersonRelationship() { PersonId = personId, //RelatedTo = relatedTo, RelationshipTypeId = relationshipType }; return(_result = _mgr.AddPersonRelationship(personRelatioship)); }
protected override string ConstructSuggestionReason(Entity e) { if (e != null) { PersonRelationship pr = (PersonRelationship)e; return(pr.RelationshipSummary(this.Person) + " and " + (pr.SubjectPerson != this.Person ? pr.SubjectPerson.Name : pr.ObjectPerson.Name) + " has responsibility for this event" + (pr.HasIncompleteDate() ? " (some dates are incomplete)." : ".")); } return(string.Empty); }
public ActionResult Edit(int personId, int relationshipId) { PersonRelationship relationship = this.personTasks.GetPersonRelationship(relationshipId); Person person = this.personTasks.GetPerson(personId); if (relationship != null && person != null) { PersonRelationshipViewModel vm = new PersonRelationshipViewModel(relationship); return(View(vm)); } return(new HttpNotFoundResult()); }
public int AddPatientFamilyTestings(PatientFamilyTesting p, int userId) { PersonManager pm = new PersonManager(); int personId = pm.AddPersonUiLogic(p.FirstName, p.MiddleName, p.LastName, p.Sex, userId, p.DateOfBirth, p.DobPrecision); PersonRelationship relationship = new PersonRelationship() { PersonId = personId, PatientId = p.PatientId, BaselineResult = p.BaseLineHivStatusId, BaselineDate = p.BaselineHivStatusDate, RelationshipTypeId = p.RelationshipId, CreatedBy = userId }; _personRelationshipManager.AddPersonRelationship(relationship); DateTime?testingDate = p.HivTestingResultsDate; if (testingDate == DateTime.MinValue) { testingDate = null; } PatientHivTesting familyTesting = new PatientHivTesting() { PersonId = personId, PatientMasterVisitId = p.PatientMasterVisitId, TestingResult = p.HivTestingResultsId, TestingDate = testingDate, ReferredToCare = p.CccReferal, CreatedBy = userId }; int hivTestingId = _hivTestingManager.AddPatientHivTesting(familyTesting); if (p.CccReferal == true) { PatientLinkage patientLinkage = new PatientLinkage() { PersonId = personId, LinkageDate = (DateTime)p.LinkageDate, CCCNumber = p.CccReferaalNumber, CreatedBy = userId }; linkageManager.AddPatientLinkage(patientLinkage); } return(hivTestingId); }
public async Task <PersonRelationship> UpdatePersonRelationship(PersonRelationship personRelationship) { try { _unitOfWork.Repository <PersonRelationship>().Update(personRelationship); await _unitOfWork.SaveAsync(); return(personRelationship); } catch (Exception e) { Console.WriteLine(e); throw e; } }
public JsonNetResult Delete(int personId, int relationshipId) { PersonRelationship relationship = this.personTasks.GetPersonRelationship(relationshipId); Person person = this.personTasks.GetPerson(personId); if (relationship != null && person != null) { this.personTasks.DeletePersonRelationship(relationship); Response.StatusCode = (int)HttpStatusCode.OK; return(JsonNet("Person relationship successfully deleted.")); } else { Response.StatusCode = (int)HttpStatusCode.NotFound; return(JsonNet("Person or person relationship not found.")); } }
public JsonNetResult Add(PersonRelationshipViewModel vm) { if (ModelState.IsValid) { PersonRelationship relationship = new PersonRelationship(); Mapper.Map <PersonRelationshipViewModel, PersonRelationship>(vm, relationship); relationship.SubjectPerson = this.personTasks.GetPerson(vm.SubjectPersonId.Value); relationship.ObjectPerson = this.personTasks.GetPerson(vm.ObjectPersonId.Value); relationship.PersonRelationshipType = this.personTasks.GetPersonRelationshipType(vm.PersonRelationshipTypeId.Value); relationship = this.personTasks.SavePersonRelationship(relationship); return(JsonNet(string.Empty)); } else { return(JsonNet(this.GetErrorsForJson())); } }
public int UpdatePersonRelationship(PersonRelationship personRelationship) { using (UnitOfWork unitOfWork = new UnitOfWork(new PersonContext())) { try { unitOfWork.PersonRelationshipRepository.Update(personRelationship); return(_result = unitOfWork.Complete()); } catch (Exception e) { Console.WriteLine(e); throw; } finally { unitOfWork.Dispose(); } } }
public Person DeepCopyV1() { Person clone = (Person)this.MemberwiseClone(); clone.PersonID = string.Copy(this.PersonID); PersonAdress perAdrClone = PersonAdress.GetClone(); clone.PersonAdress = perAdrClone; PersonJob perJobClone = PersonJob.GetClone(); clone.PersonJob = perJobClone; PersonRelationship perRelClone = RelationShip.GetClone(); clone.RelationShip = perRelClone; return(clone); }
public PersonRelationship GetSpecificRelationship(int personId, int patientId) { using (UnitOfWork unitOfWork = new UnitOfWork(new PersonContext())) { try { PersonRelationship pm = unitOfWork.PersonRelationshipRepository .FindBy(x => x.PersonId == personId && x.PatientId == patientId).FirstOrDefault(); return(pm); } catch (Exception e) { Console.WriteLine(e); throw; } finally { unitOfWork.Dispose(); } } }
public PersonRelationship SavePersonRelationship(PersonRelationship relationship) { relationship.SubjectPerson.AddPersonRelationshipAsSubject(relationship); relationship.ObjectPerson.AddPersonRelationshipAsObject(relationship); Person subject = relationship.SubjectPerson; Person objectP = relationship.ObjectPerson; if (!subject.HasValidProfileStatus()) { subject.ProfileStatus = this.GetProfileStatus(ProfileStatus.ROUGH_OUTLINE); this.SavePerson(subject); } if (!objectP.HasValidProfileStatus()) { objectP.ProfileStatus = this.GetProfileStatus(ProfileStatus.ROUGH_OUTLINE); this.SavePerson(objectP); } return(this.personRelationshipRepo.SaveOrUpdate(relationship)); }
public void AddLinkedPatientFamilyTesting(int personId, int patientId, int patientMasterVisitId, int baselineResult, DateTime baselineDate, int relationshipTypeId, int userId, string cccNumber) { PersonRelationship relationship = new PersonRelationship(); relationship.PersonId = personId; relationship.PatientId = patientId; relationship.BaselineResult = baselineResult; relationship.BaselineDate = baselineDate; relationship.RelationshipTypeId = relationshipTypeId; relationship.CreatedBy = userId; _personRelationshipManager.AddPersonRelationship(relationship); PatientHivTesting familyTesting = new PatientHivTesting() { PersonId = personId, PatientMasterVisitId = patientMasterVisitId, TestingResult = 0, TestingDate = null, ReferredToCare = true, CreatedBy = userId }; int hivTestingId = _hivTestingManager.AddPatientHivTesting(familyTesting); PatientLinkage patientLinkage = new PatientLinkage() { PersonId = personId, LinkageDate = DateTime.Now, CCCNumber = cccNumber, CreatedBy = userId }; linkageManager.AddPatientLinkage(patientLinkage); }
public async Task <IActionResult> DeleteSingleRelation([FromBody] SingleRelation relation) { return(PersonRelationship.DeleteRelation(relation).Result.ErrorCode == ErrorList.OK ? Ok("Relation Deleted") : NotFound("relation was not found")); }
public int AddPatientFamilyTestingsExisting(PatientFamilyTesting p, int userId, int RelationshipPersonId) { int personId = RelationshipPersonId; PersonRelationship personrrel = _personRelationshipManager.GetSpecificRelationship(personId, p.PatientId); if (personrrel != null) { personrrel.PersonId = personId; personrrel.PatientId = p.PatientId; personrrel.BaselineResult = p.BaseLineHivStatusId; personrrel.BaselineDate = p.BaselineHivStatusDate; personrrel.RelationshipTypeId = p.RelationshipId; personrrel.CreatedBy = userId; _personRelationshipManager.UpdatePersonRelationship(personrrel); } else { PersonRelationship relationship = new PersonRelationship() { PersonId = personId, PatientId = p.PatientId, BaselineResult = p.BaseLineHivStatusId, BaselineDate = p.BaselineHivStatusDate, RelationshipTypeId = p.RelationshipId, CreatedBy = userId }; outcome = _personRelationshipManager.AddPersonRelationship(relationship); } if (p.CccReferaalNumber != null) { string value = (p.CccReferaalNumber == null)? "" : p.CccReferaalNumber.ToString(); if (String.IsNullOrEmpty(value) == true) { DateTime?testingDate = p.HivTestingResultsDate; if (testingDate == DateTime.MinValue) { testingDate = null; } PatientHivTesting familyTesting = new PatientHivTesting() { PersonId = personId, PatientMasterVisitId = p.PatientMasterVisitId, TestingResult = p.HivTestingResultsId, TestingDate = testingDate, ReferredToCare = p.CccReferal, CreatedBy = userId }; outcome = _hivTestingManager.AddPatientHivTesting(familyTesting); if (p.CccReferal == true) { PatientLinkage patientLinkage = new PatientLinkage() { PersonId = personId, LinkageDate = (DateTime)p.LinkageDate, CCCNumber = p.CccReferaalNumber, CreatedBy = userId }; linkageManager.AddPatientLinkage(patientLinkage); } } } return(outcome); }
public async Task <IActionResult> DeletePersonRelationsAll(string id) { return(PersonRelationship.DeleteRelationsAll(id).Result.ErrorCode == ErrorList.OK ? Ok("Relations Deleted") : NotFound("User Doesn't have relations")); }
public void Reset() { _relationship = new PersonRelationship(EnumRelationship.Unknown); }
public async Task <Result <AddPersonEmergencyContactResponse> > Handle(PersonEmergencyContactCommand request, CancellationToken cancellationToken) { try { RegisterPersonService rs = new RegisterPersonService(_unitOfWork); if (request.emergencycontacts != null || request.emergencycontacts.Count > 0) { foreach (EmergencyContact em in request.emergencycontacts) { if (em.PersonId > 0) { if (em.EmergencyContactPersonId > 0) { PersonEmergencyContact pme = new PersonEmergencyContact(); PersonEmergencyContact pmt = new PersonEmergencyContact(); if (em.emgEmergencyContactType > 0) { pme = await rs.GetSpecificEmergencyContacts(Convert.ToInt32(em.EmergencyContactPersonId), em.PersonId); //pmt = await rs.GetNextofkinEmergencyContacts(Convert.ToInt32(em.EmergencyContactPersonId), em.PersonId); if (pme != null) { pme.PersonId = em.PersonId; pme.EmergencyContactPersonId = em.EmergencyContactPersonId; pme.MobileContact = em.MobileContact; pme.CreatedBy = em.CreatedBy; pme.DeleteFlag = em.DeleteFlag; pme.ContactType = em.emgEmergencyContactType; pme.RegisteredToClinic = em.RegisteredToClinic; int res = await rs.UpdatePersonEmergencyContact(pme); if (res > 0) { msg += "Person Emergency Mobile Contact Updated Successfully"; personEmergencyContactId = em.EmergencyContactPersonId; } } else { PersonEmergencyContact pmm = new PersonEmergencyContact() { PersonId = em.PersonId, EmergencyContactPersonId = em.EmergencyContactPersonId, MobileContact = em.MobileContact, CreatedBy = em.CreatedBy, DeleteFlag = em.DeleteFlag, ContactType = em.emgEmergencyContactType, RegisteredToClinic = em.RegisteredToClinic }; PersonEmergencyContact pmeid = new PersonEmergencyContact(); pmeid = await rs.AddPersonEmergencyContact(pmm); if (pmeid != null) { msg += "New Person Emergencycontact Added successfully"; } } var personconsent = await rs.GetCurrentPersonConsent(em.EmergencyContactPersonId, Convert.ToInt32(em.PersonId)); if (personconsent != null) { personconsent.ConsentType = em.ConsentType; personconsent.ConsentValue = em.ConsentValue; personconsent.ConsentDate = DateTime.Now; personconsent.ConsentReason = em.ConsentReason; int consent = await rs.UpdatePersonConsent(personconsent); if (consent > 0) { msg += "Person Consent has been updated successfully"; } } else { PersonConsent pcs = new PersonConsent(); pcs.PersonId = em.PersonId; pcs.EmergencyContactId = em.EmergencyContactPersonId; pcs.ConsentType = em.ConsentType; pcs.ConsentValue = em.ConsentValue; pcs.ConsentDate = DateTime.Now; pcs.ConsentReason = em.ConsentReason; var perc = await rs.AddPersonConsent(pcs); if (perc != null) { msg += "Person Consent Has been added successfully"; } } Person per = new Person(); per.FirstName = em.firstname; per.MidName = em.middlename; per.LastName = em.lastname; per.Sex = em.gender; per.Id = em.EmergencyContactPersonId; var resupd = await rs.UpdateEmergencyPerson(per); if (resupd != null) { msg += "PersonEmergencyContact updated successfully"; } } if (em.emgNextofKinContactType > 0) { pmt = await rs.GetNextofkinEmergencyContacts(Convert.ToInt32(em.EmergencyContactPersonId), em.PersonId); if (pmt != null) { pmt.PersonId = em.PersonId; pmt.EmergencyContactPersonId = em.EmergencyContactPersonId; pmt.MobileContact = em.MobileContact; pmt.CreatedBy = em.CreatedBy; pmt.DeleteFlag = em.DeleteFlag; pmt.ContactType = em.emgNextofKinContactType; pmt.RegisteredToClinic = em.RegisteredToClinic; int res = await rs.UpdatePersonEmergencyContact(pmt); if (res > 0) { msg += "Person Emergency Mobile Contact Updated Successfully"; personEmergencyContactId = em.EmergencyContactPersonId; } } else { PersonEmergencyContact pmm = new PersonEmergencyContact() { PersonId = em.PersonId, EmergencyContactPersonId = em.EmergencyContactPersonId, MobileContact = em.MobileContact, CreatedBy = em.CreatedBy, DeleteFlag = em.DeleteFlag, ContactType = em.emgEmergencyContactType, RegisteredToClinic = em.RegisteredToClinic }; PersonEmergencyContact pmeid = new PersonEmergencyContact(); pmeid = await rs.AddPersonEmergencyContact(pmm); if (pmeid != null) { msg += "New Person Emergencycontact Added successfully"; } } var personconsent = await rs.GetCurrentPersonConsent(em.EmergencyContactPersonId, Convert.ToInt32(em.PersonId)); if (personconsent != null) { personconsent.ConsentType = em.ConsentType; personconsent.ConsentValue = em.ConsentValue; personconsent.ConsentDate = DateTime.Now; personconsent.ConsentReason = em.ConsentReason; int consent = await rs.UpdatePersonConsent(personconsent); if (consent > 0) { msg += "Person Consent has been updated successfully"; } } else { if (em.ConsentValue > 0) { PersonConsent pcs = new PersonConsent(); pcs.PersonId = em.PersonId; pcs.EmergencyContactId = pme.Id; pcs.ConsentType = em.ConsentType; pcs.ConsentValue = em.ConsentValue; pcs.ConsentDate = DateTime.Now; pcs.ConsentReason = em.ConsentReason; var perc = await rs.AddPersonConsent(pcs); if (perc != null) { msg += "Person Consent Has been added successfully"; } } } Person per = new Person(); per.FirstName = em.firstname; per.MidName = em.middlename; per.LastName = em.lastname; per.Sex = em.gender; per.Id = em.EmergencyContactPersonId; var resupda = await rs.UpdateEmergencyPerson(per); if (resupda != null) { msg += "PersonEmergencyContact updated successfully"; } } } else { var personEmerg = await rs.InsertPerson(em.firstname, em.middlename, em.lastname, em.gender, em.CreatedBy); if (personEmerg != null) { personEmergencyContactId = personEmerg.Id; if (em.emgEmergencyContactType > 0) { PersonEmergencyContact pmm = new PersonEmergencyContact() { PersonId = em.PersonId, EmergencyContactPersonId = personEmerg.Id, MobileContact = em.MobileContact, CreatedBy = em.CreatedBy, DeleteFlag = em.DeleteFlag, ContactType = em.emgEmergencyContactType, RegisteredToClinic = em.RegisteredToClinic }; PersonEmergencyContact pmeid = new PersonEmergencyContact(); pmeid = await rs.AddPersonEmergencyContact(pmm); if (pmeid != null) { msg += "New Person Emergencycontact Added successfully"; } } if (em.emgNextofKinContactType > 0) { PersonEmergencyContact pmm = new PersonEmergencyContact() { PersonId = em.PersonId, EmergencyContactPersonId = personEmerg.Id, MobileContact = em.MobileContact, CreatedBy = em.CreatedBy, DeleteFlag = em.DeleteFlag, ContactType = em.emgNextofKinContactType, RegisteredToClinic = em.RegisteredToClinic }; PersonEmergencyContact pmeid = new PersonEmergencyContact(); pmeid = await rs.AddPersonEmergencyContact(pmm); if (pmeid != null) { msg += "New Person Emergencycontact Added successfully"; } } if (em.ConsentValue > 0) { PersonConsent pcs = new PersonConsent(); pcs.PersonId = em.PersonId; pcs.EmergencyContactId = personEmergencyContactId; pcs.ConsentType = em.ConsentType; pcs.ConsentValue = em.ConsentValue; pcs.ConsentDate = DateTime.Now; pcs.ConsentReason = em.ConsentReason; var perc = await rs.AddPersonConsent(pcs); if (perc != null) { msg += "Person Consent Has been added successfully"; } } PersonRelationship pl = new PersonRelationship(); var personrel = await rs.AddPersonRelationship(em.PersonId, personEmerg.Id, em.RelationshipType, em.CreatedBy); if (personrel != null) { msg += "Person EmergencyContact relationship added successfully"; } } } } } } return(Result <AddPersonEmergencyContactResponse> .Valid(new AddPersonEmergencyContactResponse() { Message = msg, PersonEmergencyContactId = personEmergencyContactId })); } catch (Exception e) { return(Result <AddPersonEmergencyContactResponse> .Invalid(e.Message)); } }
public PersonRelationshipService() { _relationship = new PersonRelationship(EnumRelationship.Unknown); }
private static void AddPersonRelationship(int personId, int personRelatedToId, int relationshipId, Person familyMemberToUpdate, oikonomosEntities context) { bool found = false; foreach (PersonRelationship rel in familyMemberToUpdate.PersonRelationships) { //Update the existing one if (rel.PersonRelatedToId == personRelatedToId) { if (rel.RelationshipId != relationshipId) { rel.RelationshipId = relationshipId; rel.Changed = DateTime.Now; } found = true; break; } } if (!found) { //Create a new one PersonRelationship newRelationship = new PersonRelationship(); newRelationship.PersonRelatedToId = personRelatedToId; newRelationship.RelationshipId = relationshipId; newRelationship.PersonId = personId; newRelationship.Created = DateTime.Now; newRelationship.Changed = DateTime.Now; context.AddToPersonRelationships(newRelationship); } }
public void DeletePersonRelationship(PersonRelationship relationship) { relationship.SubjectPerson.RemovePersonRelationshipAsSubject(relationship); relationship.ObjectPerson.RemovePersonRelationshipAsObject(relationship); this.personRelationshipRepo.Delete(relationship); }