public int AddMember(NewMember newMember)
        {
            var gender = string.IsNullOrEmpty(newMember.Gender) ? (char?)null : newMember.Gender[0];

            using (var scope = new TransactionScope())
            {
                var dbMember = new DataModel.Generated.Member()
                {
                    FirstName      = newMember.FirstName,
                    LastName       = newMember.LastName,
                    DOB            = newMember.DateOfBirth,
                    Gender         = gender.ToString(),
                    Phone          = newMember.Phone,
                    Email          = newMember.Email,
                    SpouseMemberId = newMember.SpouseMemberId,
                    FatherMemberId = newMember.FatherMemberId,
                    MotherMemberId = newMember.MotherMemberId,
                    IsHeadOfFamily = newMember.IsHeadOfFamily
                };
                _unitOfWork.MemberRepository.Insert(dbMember);
                _unitOfWork.Save();

                if (newMember.SpouseMemberId.HasValue)
                {
                    var spouseMember =
                        _unitOfWork.MemberRepository.GetFirst(m => m.MemberId == newMember.SpouseMemberId.Value);
                    spouseMember.SpouseMemberId = dbMember.MemberId;
                    _unitOfWork.MemberRepository.Update(spouseMember);
                    _unitOfWork.Save();
                }
                scope.Complete();
                return(dbMember.MemberId);
            }
        }
        public int AddKfcMember(int parentId, NewMember newMember)
        {
            using (var scope = new TransactionScope())
            {
                var dbMember = new DataModel.Generated.Member()
                {
                    FirstName = newMember.FirstName,
                    LastName  = newMember.LastName,
                    DOB       = newMember.DateOfBirth,
                    Gender    = newMember.Gender.ToString(),
                    Phone     = newMember.Phone,
                    Email     = newMember.Email,
                    MemberOf  = "KFC"
                };
                _unitOfWork.MemberRepository.Insert(dbMember);
                _unitOfWork.Save();

                var dbMemberMembership = new DataModel.Generated.MemberMembership()
                {
                    MemberId  = dbMember.MemberId,
                    MemberOf  = "KFC",
                    StartDate = DateTime.Now.Date
                };
                _unitOfWork.MemberMembershipRepository.Insert(dbMemberMembership);
                _unitOfWork.Save();
                scope.Complete();
                return(dbMember.MemberId);
            }
        }
        public int AddSpouseOfMember(int spouseMemberId, NewMember newMember)
        {
            using (var scope = new TransactionScope())
            {
                var dbMember = new DataModel.Generated.Member()
                {
                    FirstName      = newMember.FirstName,
                    LastName       = newMember.LastName,
                    DOB            = newMember.DateOfBirth,
                    Gender         = newMember.Gender.ToString(),
                    Phone          = newMember.Phone,
                    Email          = newMember.Email,
                    SpouseMemberId = spouseMemberId
                };
                _unitOfWork.MemberRepository.Insert(dbMember);
                _unitOfWork.Save();
                var newMemberId = dbMember.MemberId;

                var spouse = _unitOfWork.MemberRepository.Get(u => u.MemberId == spouseMemberId);
                spouse.SpouseMemberId = newMemberId;
                _unitOfWork.MemberRepository.Update(spouse);
                _unitOfWork.Save();

                scope.Complete();
                return(dbMember.MemberId);
            }
        }
        public int AddKfcMember(int parentId, NewMember newMember)
        {
            using (var scope = new TransactionScope())
            {
                var dbMember = new DataModel.Generated.Member()
                {
                    FirstName = newMember.FirstName,
                    LastName = newMember.LastName,
                    DOB = newMember.DateOfBirth,
                    Gender = newMember.Gender.ToString(),
                    Phone = newMember.Phone,
                    Email = newMember.Email,
                    MemberOf = "KFC"
                };
                _unitOfWork.MemberRepository.Insert(dbMember);
                _unitOfWork.Save();

                var dbMemberMembership = new DataModel.Generated.MemberMembership()
                {
                    MemberId = dbMember.MemberId,
                    MemberOf = "KFC",
                    StartDate = DateTime.Now.Date
                };
                _unitOfWork.MemberMembershipRepository.Insert(dbMemberMembership);
                _unitOfWork.Save();
                scope.Complete();
                return dbMember.MemberId;
            }
        }
        public int AddMember(NewMember newMember)
        {
            var gender = string.IsNullOrEmpty(newMember.Gender) ? (char?)null : newMember.Gender[0];
            using (var scope = new TransactionScope())
            {
                var dbMember = new DataModel.Generated.Member()
                {
                    FirstName = newMember.FirstName,
                    LastName = newMember.LastName,
                    DOB = newMember.DateOfBirth,
                    Gender = gender.ToString(),
                    Phone = newMember.Phone,
                    Email = newMember.Email,
                    SpouseMemberId = newMember.SpouseMemberId,
                    FatherMemberId = newMember.FatherMemberId,
                    MotherMemberId = newMember.MotherMemberId,
                    IsHeadOfFamily = newMember.IsHeadOfFamily
                };
                _unitOfWork.MemberRepository.Insert(dbMember);
                _unitOfWork.Save();

                if (newMember.SpouseMemberId.HasValue)
                {
                    var spouseMember =
                        _unitOfWork.MemberRepository.GetFirst(m => m.MemberId == newMember.SpouseMemberId.Value);
                    spouseMember.SpouseMemberId = dbMember.MemberId;
                    _unitOfWork.MemberRepository.Update(spouseMember);
                    _unitOfWork.Save();
                }
                scope.Complete();
                return dbMember.MemberId;
            }
        }
        public int AddSpouseOfMember(int spouseMemberId, NewMember newMember)
        {
            using (var scope = new TransactionScope())
            {
                var dbMember = new DataModel.Generated.Member()
                {
                    FirstName = newMember.FirstName,
                    LastName = newMember.LastName,
                    DOB = newMember.DateOfBirth,
                    Gender = newMember.Gender.ToString(),
                    Phone = newMember.Phone,
                    Email = newMember.Email,
                    SpouseMemberId = spouseMemberId
                };
                _unitOfWork.MemberRepository.Insert(dbMember);
                _unitOfWork.Save();
                var newMemberId = dbMember.MemberId;

                var spouse = _unitOfWork.MemberRepository.Get(u => u.MemberId == spouseMemberId);
                spouse.SpouseMemberId = newMemberId;
                _unitOfWork.MemberRepository.Update(spouse);
                _unitOfWork.Save();

                scope.Complete();
                return dbMember.MemberId;
            }
        }