internal static FamilyMember NewFamilyMember(string name, Gender gender, string dateOfBirth, string parentName) { DateTime? trialDateOfBirth = null; if (dateOfBirth != null) trialDateOfBirth = DateTime.Parse(dateOfBirth); var familyMember = new FamilyMember { _name = name, _gender = gender, _dateOfBirth = trialDateOfBirth }; if (!string.IsNullOrEmpty(parentName)) { var parent = GetFamilyMemberByName(parentName); if (parent != null) familyMember._parentId = parent.FamilyMemberId; } return familyMember; }
private static void Delete(FamilyMember familyMember) { if (_deleteMode == DeleteMode.CascadeDelete) { var familyMembersArray = _familyMembers.ToArray(); foreach (var member in familyMembersArray) { if (member.ParentId == familyMember.FamilyMemberId) Delete(member); } } else { var familyMembersArray = _familyMembers.ToArray(); foreach (var member in familyMembersArray) { if (member.ParentId == familyMember.FamilyMemberId) { if (_deleteMode == DeleteMode.BypassDeletedNode) member.ParentId = familyMember.ParentId; else //if (_deleteMode == DeleteMode.OrphanChildNodes) member.ParentId = null; member.Save(); } } } familyMember.IsDeleted = true; _familyMembers.Remove(familyMember); FamilyMemberInfo.Remove(familyMember.FamilyMemberId); if (_deleteMode != DeleteMode.CascadeDelete) FamilyMemberInfo.GetFamilyMemberInfoList().RaiseResetEvent(); }
public static FamilyMember AddNewFamilyMember(int? parentId, string nodeNameToShow) { var familyMember = new FamilyMember { ParentId = parentId, IsDirty = true }; _familyMembers.Add(familyMember); FamilyMemberInfo.AddNewFamilyMemberInfo(familyMember.FamilyMemberId, nodeNameToShow, familyMember.ParentId); return familyMember; }