コード例 #1
0
        public void RemoveLink(long userId, long linkId)
        {
            if (!UserDao.Exists(userId))
            {
                throw new InstanceNotFoundException <UserProfileDetails>("userId", userId);
            }

            Link link;

            try
            {
                link = LinkDao.Find(linkId);
            }
            catch (InstanceNotFoundException <Link> ex)
            {
                throw new InstanceNotFoundException <LinkDetails>(ex.Properties);
            }

            if (link.UserProfile.userId != userId)
            {
                throw new UserNotAuthorizedException <LinkDetails>(userId, "linkId", linkId);
            }

            try
            {
                LinkDao.Remove(linkId);
            }
            catch (InstanceNotFoundException <Link> ex)
            {
                throw new InternalErrorException(ex);
            }
        }