Exemple #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);
        }