views:

8

answers:

0

Hi

I have a WCF Service method SavePlannerData that has one of input Guid datatype. Now if there is no Guid, it is coming as EmptyString ("") instead of null. If it is null, it is working fine. If it is emptystring, it is not calling WCfService and It is throwing the following error: Error in deserializing body of request message for operation. But i want to handle the case even if it is emptystring.

Wondering if anyone came across same issue to handle this and make call to WCF method and handle it in C#.

Code:

function WcfSavePlannerData() {
        debugger;
        var response = null;
        var IssueNumber = $('#txtissueidAssess').val();
        var BatchNumber = $('#txtbatchidAssess').val();
        var AssessmentType = $('#txtAssessTypeId').val();
        var AssessId = $('#txtExistingAssessmentId').val();
        var GuidelineGuid = "{18AF22EC-7FCA-DF11-8152-080027FD54E2}";
        var plannerData = {
            "plannerData":
            {
                "Assessments": [
                    {
                        "AssessmentTypeGuid": "",
                        "GuidelineGuid": GuidelineGuid,
                        "IssueGuid": IssueNumber,
                        "ManufacturingStageId": 929280005,
                        "BatchNumberGuid": BatchNumber,
                        "ManufacturingSiteId": 929280006,
                        "InvestigationSiteId": 929280006,
                        "AssessmentOwnerGuid": null,
                        "RejectionJustification": "Rejected"
                    }
                ]
            }
        };
        $.ajax({
            async: false,
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "http://localhost:54325/InvestigationGuidelines.svc/SavePlannerData",
            dataType: "json",
            data: plannerData,
            error: function (request, textStatus, error) { alert(request.responseText + "\r\n" + textStatus + "\r\n" + error); },
            success: function (respdata, textStatus, request) { response = respdata == null ? null : respdata.d; }
        });
        return response;
    };

Server-Sode code in WCFService:

public Boolean SavePlannerData(PlannerData plannerData)
    {
        //Saves the Planner Data as it is coming as JSon String
        plannerData.Assessments.ToList().ForEach(assessment =>
                {
                    SaveAssessment(assessment);
                });

        return true;
    }

In the above code, I want to handle even if AssessmentTypeGuid = "".

Appreciate your time.

Thanks