0

jQuery:

var mmr = new Mmr.FormData().mmr;
    $.ajax({
        contentType: 'application/json; charset=utf-8',
        url: "/Property/Mmr/Submit",
        data: JSON.stringify(mmr),
        success: function () {
            alert("success");
        },
        dataType: "json",
        method: "POST",
        error: function () {
            alert("failure");
        }
    });

我的控制器:

[HttpPost]
public string Submit(MonthlyMarketingReport report)
{
    return "SUCCESS";
}

报告都是空数据。我不确定为什么。

这是发布的 json ......(它来自从 c# 模型转换的 TypeScript 类,所以这应该是正确的......)

{
    "RecentSale1": {
        "Street": "123",
        "City": "123123",
        "State": "CA",
        "Zip": "12313",
        "SaleDate": "08/07/2013",
        "Condition": "Fair",
        "SqFt": "213",
        "Bedrooms": "2",
        "Baths": "2",
        "Parking": "Drvwy",
        "Yearbuilt": "2",
        "DaysOnMarket": "2",
        "ListDate": "3",
        "SalePrice": "123",
        "Comments": "123"
    },
    "RecentSale2": {
        "Street": "123123",
        "City": "123123",
        "State": "FL",
        "Zip": "12343",
        "SaleDate": "08/07/2013",
        "Condition": "Fair",
        "SqFt": "123",
        "Bedrooms": "2",
        "Baths": "2",
        "Parking": "Attch3",
        "Yearbuilt": "1234",
        "DaysOnMarket": "3",
        "ListDate": "123",
        "SalePrice": "123",
        "Comments": "asfasdf"
    },
    "RecentSale3": {
        "Street": "13123",
        "City": "123",
        "State": "AK",
        "Zip": "12313",
        "SaleDate": "08/09/2013",
        "Condition": "Avg",
        "SqFt": "123",
        "Bedrooms": "1",
        "Baths": "12",
        "Parking": "Drvwy",
        "Yearbuilt": "123",
        "DaysOnMarket": "123",
        "ListDate": "123",
        "SalePrice": "123123",
        "Comments": "123123123"
    },
    "CurrentListing1": {
        "Street": "123",
        "City": "123",
        "State": "AZ",
        "Zip": "12323",
        "ListDate": "08/01/2013",
        "Condition": "Poor",
        "SqFt": "12312",
        "Bedrooms": "12",
        "Baths": "2",
        "Parking": "Asgn",
        "Yearbuilt": "123",
        "DaysOnMarket": "123",
        "CurrentListPrice": "123",
        "OriginalListPrice": "123123",
        "Comments": "123123"
    },
    "CurrentListing2": {
        "Street": "123",
        "City": "123",
        "State": "AZ",
        "Zip": "123",
        "ListDate": "08/13/2013",
        "Condition": "Fair",
        "SqFt": "123",
        "Bedrooms": "12",
        "Baths": "2",
        "Parking": "Asgn",
        "Yearbuilt": "123",
        "DaysOnMarket": "23",
        "CurrentListPrice": "23",
        "OriginalListPrice": "3123",
        "Comments": "123123123"
    },
    "CurrentListing3": {
        "Street": "2",
        "City": "323",
        "State": "AK",
        "Zip": "12312",
        "ListDate": "08/09/2013",
        "Condition": "Good",
        "SqFt": "123",
        "Bedrooms": "2",
        "Baths": "1",
        "Parking": "Asgn",
        "Yearbuilt": "3213",
        "DaysOnMarket": "123",
        "CurrentListPrice": "123123",
        "OriginalListPrice": "213123",
        "Comments": "123123123123213"
    },
    "LocalListingsCount": "234",
    "LocalDaysOnMarketAverage": "234",
    "LocalPriceLow": "23423",
    "LocalPriceHigh": "4234234",
    "LocalCompetition": "Decreasing",
    "LocalCondition": "Interior",
    "LocalPriceRange": "Interior",
    "Showings": "123",
    "ShowingsTotal": "123",
    "TourDateLast": "08/08/2013",
    "OpenHouseDateLast": "08/05/2013",
    "CommentsBuyerPositive": "dsfsd",
    "CommentsBuyerNegative": "sdfsd",
    "IsRepairsRecomended": true,
    "IsRepairsReccomendedExplain": "fsdfs",
    "IsRepairsEstimate": "123",
    "IsFinanced": false,
    "IsFinancedExplain": "sdfsd",
    "NotSoldExplain": "sdfsdf",
    "IsMarketedWhileOccupied": true,
    "IsMarketedWhileOccupiedExplain": "sdafsdf",
    "IsCodeViolation": true,
    "IsCodeViolationExplain": "sdf",
    "IsForSaleSign": false,
    "IsForSaleSignExplain": "123123",
    "IsClean": false,
    "IsCleanExplain": "fsdfsd",
    "IsTrashout": false,
    "IsTrashoutExplain": "adsfasdf",
    "IsUtilitiesOn": false,
    "IsUtilitiesOnExplain": "f",
    "IsWinterized": false,
    "IsWinterizedExplain": "sdfsdf",
    "IsHazard": true,
    "IsHazardExplain": "dfsdf",
    "IsRepairsCompleted": false,
    "IsRepairsCompletedExplain": "sdfsd",
    "IsVandalized": true,
    "IsInsuranceClaim": true,
    "CurrentCondition": "fsdfsdfdsfsdf",
    "MarketingStrategy": "asdfsdfsdf",
    "PriceRecommended": ""
}

我的每月营销报告课

public partial class MonthlyMarketingReport : Reports
{
    public Nullable<int> MarketingPlanId { get; set; }
    public bool IsMarketedWhileOccupied { get; set; }
    public string IsMarketedWhileOccupiedExplain { get; set; }
    public bool IsCodeViolation { get; set; }
    public string IsCodeViolationExplain { get; set; }
    public bool IsForSaleSign { get; set; }
    public string IsForSaleSignExplain { get; set; }
    public bool IsClean { get; set; }
    public string IsCleanExplain { get; set; }
    public bool IsTrashout { get; set; }
    public string IsTrashoutExplain { get; set; }
    public bool IsUtilitiesOn { get; set; }
    public string IsUtilitiesOnExplain { get; set; }
    public bool IsWinterized { get; set; }
    public string IsWinterizedExplain { get; set; }
    public bool IsHazard { get; set; }
    public string IsHazardExplain { get; set; }
    public bool IsRepairsCompleted { get; set; }
    public string IsRepairsCompletedExplain { get; set; }
    public bool IsVandalized { get; set; }
    public bool IsInsuranceClaim { get; set; }
    public string CurrentCondition { get; set; }
    public int Showings { get; set; }
    public int ShowingsTotal { get; set; }
    public System.DateTime TourDateLast { get; set; }
    public System.DateTime OpenHouseDateLast { get; set; }
    public string CommentsBuyerPositive { get; set; }
    public string CommentsBuyerNegative { get; set; }
    public bool IsRepairsRecomended { get; set; }
    public string IsRepairsReccomendedExplain { get; set; }
    public Nullable<decimal> IsRepairsEstimate { get; set; }
    public bool IsFinanced { get; set; }
    public string IsFinancedExplain { get; set; }
    public string NotSoldExplain { get; set; }
    public int LocalListingsCount { get; set; }
    public int LocalDaysOnMarketAverage { get; set; }
    public decimal LocalPriceLow { get; set; }
    public decimal LocalPriceHigh { get; set; }
    public string LocalCompetition { get; set; }
    public string LocalCondition { get; set; }
    public string LocalPriceRange { get; set; }
    public string MarketingStrategy { get; set; }
    public decimal PriceRecommended { get; set; }
    public int CompIdRecentSale1 { get; set; }
    public int CompIdRecentSale2 { get; set; }
    public int CompIdRecentSale3 { get; set; }
    public int CompIdCurrentListing1 { get; set; }
    public int CompIdCurrentListing2 { get; set; }
    public int CompIdCurrentListing3 { get; set; }

    public virtual Comparables RecentSale1 { get; set; }
    public virtual Comparables RecentSale2 { get; set; }
    public virtual Comparables RecentSale3 { get; set; }
    public virtual Comparables CurrentListing1 { get; set; }
    public virtual Comparables CurrentListing2 { get; set; }
    public virtual Comparables CurrentListing3 { get; set; }
    public virtual Album Album { get; set; }
}
4

1 回答 1

0

您的控制器操作方法的签名是

public string Submit(MonthlyMarketingReport report)

所以我认为在你的ajax调用中应该是

data: JSON.stringify({ report: mmr }),
于 2013-08-14T12:46:00.063 回答