1

kendo ui グリッドから WCF サービスを介して作成アクションを呼び出すのに苦労しています。ロジック CreateEntity メソッド。これはもともとコンテンツタイプのせいだと思っていましたが、今は疑問に思っています。フィドラーでWCFサービスに直接アクセスすると、レコードが正常に作成されます...

剣道グリッド:

これは、剣道グリッドによって呼び出されるアプリケーション レベルの Customer_Create アクションです。

@(Html.Kendo().Grid<Application.ServiceProxy.CustomerDTO>()
.Name("grid")
.Columns(columns =>
{

    columns.Bound(c => c.salesOrganizationID).Width(15).Title("sales org");
    columns.Bound(c => c.customerID).Width(20).Groupable(false);
    columns.Bound(c => c.name1).Width(25).Title("name");
    columns.Bound(c => c.city).Width(15).Title("city");
    columns.Bound(c => c.stateCode).Width(10).Title("state");
    columns.Bound(c => c.countryCode).Width(15).Title("country");
    columns.Bound(c => c.matchcode).Width(25).Title("matchcode");
    columns.Command(command => { command.Edit(); command.Destroy(); }).Width(35);
    //Add program type here CMI, VMI etc..        
    //columns.Width(25).Title("program");  

})
.ToolBar(toolbar => toolbar.Create())
.Editable(ed => ed.Mode(GridEditMode.PopUp).Window(w => w.Title("Edit Customer Details").Name("editWindow").HtmlAttributes(new { @style = "width:700px;" })))
.Pageable()
.Sortable()
.Groupable()
.Scrollable()
.Filterable()
.HtmlAttributes(new { style = "height:420px;" })
.DataSource(dataSource => dataSource
    .Ajax()
    .PageSize(20)
    .ServerOperation(true)
    .Events(events => events.Error("error_handler"))
    .Model(model => model.Id(c => c.customerID))
    .Create(update => update.Action("Customer_Create", "Customer"))
    .Read(read => read.Action("Customer_Read", "Customer"))
    .Update(update => update.Action("Customer_Update", "Customer"))
    .Destroy(update => update.Action("Customer_Delete", "Customer"))


)

)

これは、剣道グリッドによって呼び出されるアプリケーション レベルの Customer_Create アクションです。

     [System.Web.Http.HttpPost]
            public ActionResult Customer_Create([DataSourceRequest] DataSourceRequest request, Application.ServiceProxy.CustomerDTO customer)
    {

        if (customer != null && ModelState.IsValid)
        {
            var odataService = new Container(new Uri("http://localhost:8089/odata/"));
            //odataService.r
             odataService.AddToCustomer(customer);
            odataService.SaveChanges();

            return Json(ModelState.ToDataSourceResult());

        }
        return View("Index");
    }

以下は、生成された WCF データ サービスを介して呼び出される CreateEntity メソッドです。

        protected override CustomerDTO CreateEntity(CustomerDTO customerDTO)
    {

        var customer = new customer()
        {
            matchcode = customerDTO.matchcode,
            salesOrganizationID = customerDTO.salesOrganizationID,
            statusID = customerDTO.statusID,
            serviceLevelStatusID = customerDTO.serviceLevelStatusID,
            mediaIDLogo = customerDTO.mediaIDLogo,
            systemID = customerDTO.systemID,
            customerExternalSystemID = customerDTO.customerExternalSystemID,
            internationalGroup = customerDTO.internationalGroup,
            division = customerDTO.division,
            corporateID = customerDTO.corporateID,
            inventoryManagerID = customerDTO.inventoryManagerID,
            dunsNumber = customerDTO.dunsNumber
        };

        entity.customer.Add(customer);
        entity.SaveChanges();

        return GetEntityByKey(customer.customerID);
    }
4

0 に答える 0