public async Task <IActionResult> AddVideo([FromBody] VideoRequest videoRequest) { if (!await _genreManager.IsGenresIdValid(videoRequest.GenresId)) { return(BadRequest("Genres is Invalid")); } if (!await IsUser()) { return(Forbid()); } var video = _mapper.Map <Video>(videoRequest); video.LastUpdated = DateTime.Now; var author = await _authorManager.GetAuthor(videoRequest.AuthorId); if (author == null) { return(BadRequest("Author is Invalid")); } video.UserId = _userManager.GetUserId(HttpContext.User); video.AuthorId = author.Id; _videoManager.AddVideo(video); await _videoManager.SaveChangesAsync(); var response = _mapper.Map <VideoResponse>(video); return(CreatedAtAction(nameof(GetVideoById), new { id = video.Id }, response)); }