Exemplo n.º 1
0
        public long AddLink(long userId, long movieId, string name, string description, string url)
        {
            if (!UserDao.Exists(userId))
            {
                throw new InstanceNotFoundException <UserProfileDetails>("userId", userId);
            }

            if (LinkDao.ExistsForMovieAndName(movieId, name))
            {
                throw new DuplicateInstanceException <LinkDetails>("movieId", movieId, "name", name);
            }
            if (LinkDao.ExistsForMovieAndUrl(movieId, url))
            {
                throw new DuplicateInstanceException <LinkDetails>("movieId", movieId, "url", url);
            }

            Link link = Link.CreateLink(-1, movieId, userId, name, description, url, DateTime.Now);

            link.reportRead = false;

            try
            {
                LinkDao.Create(link);
            }
            catch (DuplicateInstanceException <Link> ex)
            {
                throw new DuplicateInstanceException <LinkDetails>(ex.Properties);
            }

            return(link.linkId);
        }
Exemplo n.º 2
0
        private Link CreateTestLink(UserProfile user, long movieId, string linkName, string linkDescription, string linkUrl, DateTime time)
        {
            Link link = Link.CreateLink(
                TestData.nonExistentLinkId,
                movieId,
                user.userId,
                linkName,
                linkDescription,
                linkUrl,
                Trunk(time));

            LinkDao.Create(link);

            return(link);
        }