コード例 #1
0
        private Member CreateMember(MemberReq employeeMember)
        {
            if (_mRepo.Exists(employeeMember.Cpr))
            {
                throw new MemberAlreadyExistsException();
            }

            var member = MemberFactory(employeeMember);

            member.AddMembership(new PaymentMethod());
            return(member);
        }
コード例 #2
0
 private static Member MemberFactory(MemberReq memberReq)
 {
     return(memberReq switch {
         EmployeeReq e => new Employee(e.Cpr, e.Name, e.Address, e.Phone, e.Company, e.Email, e.Magazine),
         MemberReq m => new Member(m.Cpr, m.Name)
     });