コード例 #1
0
        public void AddAwardToUser(Guid userId, Guid awardId)
        {
            Award award = awards.Find(x => x.id == awardId);

            if (award == null)
            {
                throw new ArgumentOutOfRangeException($"No award with {awardId} found");
            }

            User user = users.Find(x => x.id == userId);

            if (user == null)
            {
                throw new ArgumentOutOfRangeException($"No user with {userId} found");
            }

            if (user.GetAwards().Contains(awardId))
            {
                throw new ArgumentException($"User with {userId} already has award with {awardId}");
            }

            award.AddOwner(userId);
            user.AddAward(awardId);
        }