从angularjs接收到MVC控制器的数据为空

时间:2019-03-03 17:21:09

标签: angularjs asp.net-mvc

亲爱的,我有两个类Master和detail,分别由Raterequest和Raterequestdetails命名。我创建了一个包含两个视图模型。 在Angularjs中,我有一个包含rate的对象和一个包含orderdetails的列表。 当我调试控制器时,接收到的数据都为空 这是代码

费率请求类别

 public class RateRequests
{
    public int RateRequestsID { get; set; }
    public DateTime RateRequestsDate { get; set; }
    public string RateRequestName { get; set; }
    public string RateRequestType { get; set; }
    public string RateRequestMode { get; set; }


}

费率要求详细信息类

public class RateRequestsLines
{
    public int RateRequestsLinesID { get; set; }
    public int RateRequestsID { get; set; }
    [ForeignKey("RateRequestsID")]
    public virtual RateRequests RateRequestsFK { get; set; }
    public short FCLCNTRS { get; set; }
    public short FCLCNTRSSIZE { get; set; }
    public string FCLCNTRSTYPE { get; set; }

}

费率请求视图模型

public class RateRequestViewModel
{
    public RateRequests rate { get; set; }
    public IEnumerable<RateRequestsLines> ratelines { get; set; }
}

Angularjs

var linkers = angular.module("linkers", [])
.service("linkersSrv", function ($http) {

    var urlBase = "/LinkersEgypt/";

    this.save = function (url, ratee) {
        return $http({
            method: "POST",
            url: urlBase + "/" + url,
            data: ratee,
            ̶a̶s̶y̶n̶c̶:̶ ̶f̶a̶l̶s̶e̶,̶
        })

    };

})
.controller("linkersCon", function ($scope, linkersSrv) {

    $scope.fcl = [];

    $scope.addFCL = function () {
        $scope.fcl.push({ FCLCNTRS: $scope.ncntrs, FCLCNTRSSIZE: $scope.csize, FCLCNTRSTYPE: $scope.ctype });
        console.log($scope.fcl);
    }

    $scope.save = function () {

        var ratee = {
            rate: {
                RateRequestsDate: $scope.rdate,
                RateRequestName: $scope.rname,
                RateRequestType: $scope.rtype,
                RateRequestMode: $scope.smode
            },
            RateRequestsLines: $scope.fcl
        };

        console.log(ratee);
        var promisepost = linkersSrv.save("RateRequest/AddAllRate", ratee);
        promisepost.then(function () {
            toastr.success("Successfully saved");

        })

    }
})

费率控制器

[HttpPost]
    public JsonResult AddAllRate (RateRequestViewModel rate)
    {
        return new JsonResult();
    }

任何帮助 预先感谢

0 个答案:

没有答案