Thank you for your reply. We could not recreate the problem you described above in an empty MVC5/WebAPI project with only the DevExteme widgets added. To be clear, we are not directly using
abp.services.app.department.delete(1);
to invoke our DepartmentAppService. Instead we created a wrapper DepartmentApiController that proxies the requests to the DepartmentAppService because it appears that DevExpress' dxDataGrid.DataSource requires it.
Upon further investigation we discovered an issue using mediaformatters. We found a possible solution by adding FormUrlEncodedMediaTypeFormatter and JQueryMvcFormUrlEncodedFormatter in the PostInitialize Method of the DxAbpWebApiModule class.
To illustrate this case, we have a simple project using: Asp.Net Boilerplate project with DevExpress dxDataGrid and dxButtons. You can find it here: git clone [http://git.carelearning.com/dxabp.git])
You can see the issue if you comment out this method:
public override void PostInitialize()
{
base.PostInitialize();
Configuration.Modules.AbpWebApi().HttpConfiguration.Formatters.Add(new FormUrlEncodedMediaTypeFormatter());
Configuration.Modules.AbpWebApi().HttpConfiguration.Formatters.Add(new JQueryMvcFormUrlEncodedFormatter());
}
And then try to delete a department:
Is this approach advisable? Do you know of a better approach? We see that at aspnetboilerplate/src/Abp.Web.Api/WebApi/AbpWebApiModule.cs you are clearing all formatters except JSON. Therefore we are not sure if adding formatters will cause other problems.
Here is the webapi controller:
namespace MyCompanyName.AbpZeroTemplate.Web.Controllers.api
{
using Abp.WebApi.Controllers;
using Departments;
using Departments.Dto;
using Domain;
using Models.Dto;
using System;
using System.Collections.Generic;
using System.Web.Http;
public class DepartmentController : AbpApiController
{
public DepartmentController()
{
}
[HttpGet]
public IHttpActionResult Get()
{
var departments;
//retrieve data and pass it on--this works
return Json(departments);
}
//This fails with a 500 error:
[HttpDelete]
public void Delete(DeleteItem item)
{
if (!String.IsNullOrWhiteSpace(item.key))
_departmentAppService.Delete(item.key);
}
}
}
We tried the [FromBody] attribute and received the same result.
Thanks
Do you know yet if the Angular2 version will be developed to work with Angular CLI (<a class="postlink" href="http://cli.angular.io">http://cli.angular.io</a>)? Thank you for the hard work. We are excited about the AspNet Core and Angular2 versions!
Thank you very much your reply!
We have implemented the code you posted and it works great!
Thank you again for your hard work.
careLearning-Bill
This workaround involves creating a static method in my module IndividualConstants class and adding a using statement in the view. I am not sure this is the optimal solution but it does work.
public class IndividualConstants
{
public const string LocalizationSourceName = "Individual";
public static ILocalizableString Ls(string name) => new LocalizableString(name, LocalizationSourceName);
public static string L(string name) => Ls(name).Localize();
}
@using Individuals
<div>
<form class="form-validation" name="createIndividualForm" novalidate role="form">
<div class="modal-header">
<h4 class="modal-title">@IndividualConstants.L(IndividualConstants.IndividualCreate)</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label for="Name" class="control-label bold">@L("Name")</label>