示例#1
0
        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;
        }
示例#2
0
        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();
        }
示例#3
0
        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;
        }