コード例 #1
0
 public IActionResult RemoveVideoFromTopic([FromBody] RmoveTopicFromVideoData data)
 {
     try
     {
         var userData = jwtService.ParseData(this.User);
         this.topicService.RemoveTopicFromVideo(data, userData.UserId);
         return(Ok());
     }
     catch (ServiceException e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #2
0
        public void RemoveTopicFromVideo(RmoveTopicFromVideoData data, int userId)
        {
            var topicId = data.TopicId;
            var videoId = data.VideoId;

            var connection = this.context.VideosTopics
                             .SingleOrDefault(x => x.TopicId == topicId && x.VideoId == videoId);

            if (connection != null)
            {
                this.context.VideosTopics.Remove(connection);
                this.context.SaveChanges();
            }
        }