WebAPi中的属性路由问题

时间:2015-11-06 10:59:00

标签: angularjs asp.net-web-api asp.net-web-api2 angularjs-routing

我的控制器代码为

$scope.srchbycat = function () {
    var promisePost = MyService.getbyCat($scope.txttitle,$scope.txtGenre,$scope.txtClassification,$scope.txtDate,$scope.txtRating,$scope.txtCast);
} 

服务:

this.getbyCat = function (title, genre, classification, releaseDate, rating, cast) {
    return $http.post('/api/Movies/GetMovieByCategory',
        { Cast: cast, Classification: classification, Genre: genre, MovieId: 0, Rating: rating, ReleaseDate: releaseDate, Title: title });
    }

APICOntroller:

    [Route("api/Movies/GetMovieByCategory")]
    [HttpPost]
    public IEnumerable<MovieData> GetMovieByCategory([FromBody]MovieData movieData)  
    {  
        IEnumerable<MovieData> movieDataByCat = null;
        string[] paramCast;
        if(movieData.Cast.Count()!=0)
        paramCast = movieData.Cast;
        IEnumerable<MovieData> GetAllMovies = null;
        GetAllMovies = repo.GetAll();

        if (movieData.Cast == null || movieData.Cast.Count() == 0)
        {
            movieDataByCat = from data in GetAllMovies
                             where (data.Classification == (movieData.Classification == null ? string.Empty : movieData.Classification) ||
                                    data.Genre == (movieData.Genre == null ? string.Empty : movieData.Genre) ||
                                    data.Rating == movieData.Rating ||
                                    data.ReleaseDate == movieData.ReleaseDate ||
                                    data.Title == (movieData.Title == null ? string.Empty : movieData.Title))

                             select data;
        }
        return movieDataByCat;
    }  

问题:
我尝试调用此操作,我将能够看到在Controller和服务中传递的值,但是当APIController命中时,MovieData参数显示为null。
即使从UI传递了5个参数,也会出现两组数组。图片FYR。 Error image while debugging 什么是解决方案。

0 个答案:

没有答案