public ActionResult <Data.MovieUserData> Put(int id, [FromBody] Data.MovieUserData value)
        {
            try
            {
                var existing = repository.GetMovieUserData(id);

                if (existing == null)
                {
                    return(BadRequest("Can not find movie user data"));
                }
                mapper.Map(value, existing);
                if (value.Movie == null)
                {
                    return(BadRequest("Movie not specified"));
                }
                var movie = repository.GetMovie(value.Movie.Id);
                if (movie == null)
                {
                    return(BadRequest("Movie not found"));
                }
                existing.Movie = movie;
                repository.SaveChanges();
                return(Ok(mapper.Map <Data.MovieUserData>(existing)));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Error while saving data to db"));
            }
        }
 public ActionResult <Data.MovieUserData> Post([FromBody] Data.MovieUserData movieUserData)
 {
     try
     {
         var mapped = mapper.Map <MovieParser.Entities.MovieUserData>(movieUserData);
         if (movieUserData.Movie == null)
         {
             return(BadRequest("Movie not specified"));
         }
         var movie = repository.GetMovie(movieUserData.Movie.Id);
         if (movie == null)
         {
             return(BadRequest("Movie can not be found"));
         }
         mapped.Movie = movie;
         repository.Add(mapped);
         repository.SaveChanges();
         var link = linkGenerator.GetPathByAction("Get", "MovieUserDatas", new { id = mapped.Id });
         return(Created(link, mapper.Map <Data.MovieUserData>(mapped)));
     }
     catch (Exception)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, "Error while saving data to db"));
     }
 }