华为新系统post事件返回IHttpActionResult失效
后台返回HttpResponseMessage 类型 前台ajax中dataType: "text"
public HttpResponseMessage AddFoodSupply(HttpRequestMessage request, FoodSupplyViewModel foodModel)
{
return CreateHttpResponse(request, () =>
{
HttpResponseMessage response = null;
bool result = _foodRepository.IsExist(foodModel.room_number, foodModel.id);
if (result)
{
response = request.CreateResponse(HttpStatusCode.OK, false);
}
else
{
var food = new fd_supply();
food.UpdateFoodSupply(foodModel);
food.group_count = foodModel.group_count;
//food.group_count = _foodRepository.GetgroupCount(food.group_id);
_foodRepository.Insert(food);
_foodService.AddFoodSupply(food, foodModel.foodList);
var message = JsonConvert.SerializeObject(new { success = true, id = food.id });
return request.CreateResponse(HttpStatusCode.OK, message);
}
return response;
});
}