public void CheckUserMemberCard(int memberLevelId, long userId) { MemberCard userValidMemberCard = GetValidMemberCardOfUser(userId); if (userValidMemberCard != null && userValidMemberCard.Level.Id == memberLevelId) { throw new UserFriendlyException("you has been current member"); } }
public MemberCard CreateMemberCard(MemberCardPackage memberCardPackage, long userId) { CheckUserMemberCard(memberCardPackage.MemberLevel.Id, userId); MemberCard memberCard = new MemberCard() { Level = memberCardPackage.MemberLevel, No = MemberCard.CreateNo(), UserId = userId, Expiry = memberCardPackage.Expiry, LimitTime = Clock.Now.AddDays(memberCardPackage.Expiry) }; Repository.Insert(memberCard); return(memberCard); }