public async Task <ActionResult <VideoMediaModelOutput> > Update([FromRoute] int id, [FromBody] VideoMediaModelInput videoMediaInput)
        {
            VideoMedia videoMediaDB = await _videoMediaData.GetByID(id : id);

            if (videoMediaDB == null)
            {
                return(new NotFoundObjectResult("This video does not exist."));
            }

            VideoMedia videoMediaDBDuplicated = await _videoMediaData.GetByHashedID(hashedId : videoMediaInput.HashedID);

            if (videoMediaDBDuplicated != null && videoMediaDBDuplicated.ID != videoMediaDB.ID)
            {
                return(new ConflictObjectResult("A video with same hashedId already exists"));
            }

            VideoMedia videoMedia = _mapper.Map <VideoMedia>(videoMediaInput);

            videoMedia.ID = videoMediaDB.ID;

            VideoMedia videoMediaUpdated = await _videoMediaData.Update(videoMedia : videoMedia);

            VideoMediaModelOutput videoMediaUpdatedOutput = _mapper.Map <VideoMediaModelOutput>(videoMediaUpdated);

            return(new CreatedAtRouteResult("GetVideoMediaByID", new { id = videoMediaUpdatedOutput.ID }, videoMediaUpdatedOutput));
        }
        public async Task <ActionResult <VideoMediaModelOutput> > Insert([FromBody] VideoMediaModelInput videoMediaInput)
        {
            VideoMedia videoMediaDBDuplicated = await _videoMediaData.GetByHashedID(hashedId : videoMediaInput.HashedID);

            if (videoMediaDBDuplicated != null)
            {
                return(new ConflictObjectResult("A video with same hashedId already exists"));
            }

            VideoMedia videoMedia         = _mapper.Map <VideoMedia>(videoMediaInput);
            VideoMedia videoMediaInserted = await _videoMediaData.Insert(videoMedia : videoMedia);

            VideoMediaModelOutput videoMediaInsertedOutput = _mapper.Map <VideoMediaModelOutput>(videoMediaInserted);

            return(new CreatedAtRouteResult("GetVideoMediaByID", new { id = videoMediaInsertedOutput.ID }, videoMediaInsertedOutput));
        }
        public async Task <ActionResult <VideoMediaModelOutput> > GetByID([FromRoute] int id)
        {
            VideoMedia videoMedia = await _videoMediaData.GetByID(id : id);

            if (videoMedia == null)
            {
                return(new NotFoundObjectResult("This video does not exist."));
            }

            IEnumerable <VideoComment> videoComments = await _videoCommentData.GetAllByVideoMedia(videoMediaID : videoMedia.ID.Value);

            VideoMediaModelOutput videoMediaOutput = _mapper.Map <VideoMediaModelOutput>(videoMedia);

            videoMediaOutput.Comments = _mapper.Map <IEnumerable <VideoCommentModelOutput> >(videoComments);

            return(Ok(videoMediaOutput));
        }