JQuery Sort and Stop MVC

I get the following error when a jQuery Sort calls my sort action:

The parameter dictionary contains an invalid entry for the "DonationIDS" parameter for the "System.Web.Mvc.EmptyResult SortDonations (System.Collections.Generic.List 1[System.Int32])' in 'Vol.Web.Areas.ActivityArea.Controllers.DonationController'. The dictionary contains a value of type 'System.Collections.Generic.List1 [Vol.Models.Token]" method, but the parameter requires a value of the type "System.Collections.Generic .List`1 [System.Int32] ".
Parameter name: parameters

JQuery

$("#dlist").sortable({
        handle: '.sorthandle',
        update: function () {
            var order = $('#dlist').sortable('toArray');
            $.ajax({
                url: '/activity/donation/sortdonations',

                data: { DonationIDS: order },
                type: 'POST',
                traditional: true
            });
        }
    });

Message Values:

Parametersapplication/x-www-form-urlencoded
DonationIDS 1
DonationIDS 8
Source
DonationIDS=1&DonationIDS=8

MVC action:

 public EmptyResult SortDonations(List<int> DonationIDS)
        {


            int order = 0;
            foreach (int i in DonationIDS)
            {
                donationRepository.UpdateSortOrder(i, order);
                order++;
            }


            return new EmptyResult();
        }

It worked fine, but now it seems to refer to another class, a token. Any ideas what is happening or where to start looking?

0
source share
2 answers

enter code here , , .

     [HttpPost]
        public EmptyResult SortDonations(string[] donationorder)


{

    int order = 0; 
    foreach (var i in donationorder)
    {
        donationRepository.UpdateSortOrder(Convert.ToInt32(i), order);
        order++;
    }


    return new EmptyResult();
}
0

global.asax Application_Start

ModelMetadataProviders.Current = new DataAnnotationsModelMetadataProvider();

. : http://weblogs.asp.net/scottgu/archive/2010/12/14/update-on-asp-net-mvc-3-rc2-and-a-workaround-for-a-bug-in-it.aspx

0

Source: https://habr.com/ru/post/1714588/


All Articles