Ejemplo n.º 1
0
 public MemberModel(
     Guid id,
     AccountNo accountNo,
     string username,
     DateTime registrationDate,
     Rank rank,
     PersonalInformation personalInformation)
 {
     this.Id = id;
     this.AccountNo = accountNo;
     this.Username = username;
     this.RegistrationDate = registrationDate;
     this.Rank = rank;
     this.PersonalInformation = personalInformation;
 }
Ejemplo n.º 2
0
        public Member RegisterDownLine(
            string userName, 
            Position position, 
            AccountNo uplineAccountNo,
            PersonalInformation personalInformation)
        {
            using (var transaction = new TransactionScope())
            {
                try
                {
                    Member upline = this.uow.MemberRepository.FindByAccountNo(uplineAccountNo);
                    if (upline == null)
                    {
                        throw new ArgumentException(
                            String.Format(
                                "Can't create downline to a non-existing upline `{0}`",
                                uplineAccountNo.Number));
                    }

                    Rank initialRank = this.uow.RankRepository.GetInitialRank();

                    var member = Member.CreateDownLine(
                        Guid.NewGuid(),
                        userName,
                        personalInformation,
                        initialRank,
                        upline.Id,
                        position);

                    this.uow.MemberRepository.Add(member);
                    this.uow.Commit();

                    transaction.Complete();

                    return member;
                }
                catch (Exception ex)
                {
                    transaction.Dispose();
                    throw ex;
                }
            }
        }