コード例 #1
0
        public bool AddComment(CommentDTO commentDTO)
        {
            var user = _repository.GetUserByEmail(commentDTO.UserEmail);

            if (_repository.CheckUserPriority(user, 10) == false && _repository.CheckUserPriority(user, 20) == false)
            {
                return(false);
            }

            //var attraction = _repository.GetEntityById<Attraction>(commentDTO.AttractionId);

            //if(null == attraction.Comments)
            //{
            //    attraction.Comments = new List<Comment>();
            //}

            Comment comment = new Comment()
            {
                Attraction = new Attraction()
                {
                    Id = commentDTO.AttractionId
                },
                User           = user,
                CommentContent = commentDTO.CommentContent,
            };

            _repository.AddComment(comment);

            return(true);
        }