-1

How to receive two parameters as an array in http action(List abc, List) xyz. after that attempt I use a model class. lik

  public class ItemAndChecque
    {
        public List<SaleItem> saleitem { get; set; }
        public List<itemChecqe> itemchecq { get; set; }
    }
public IHttpActionResult TowArrayValue(List<ItemAndChecque> abc)

I did many attempt to solve it but not... Some one can send me any Solution.

br.julien
  • 3,420
  • 2
  • 23
  • 44
  • 1
    check here. I think thats what youre looking for https://stackoverflow.com/questions/30957248/how-to-send-post-in-angularjs-with-multiple-params otherwise please add more detail or example code of your work – G43beli Mar 01 '18 at 10:35

1 Answers1

0

Your arrays need to be grouped in one object array:

var Indata = {saleitem: $scope.saleitem,itemchecq: $scope.itemchecq}
$http({
  url: "someAPI",
  method: "POST",
  data: Indata
});

Add ItemAndChecque as model class to your backend.

Then you can receive it in your API Controller like this:

public void Post(ItemAndChecque request)
{
    var productRepository = new ProductRepository();
    var newProduct = productRepository.Save(request.product);
}

Here request contains 2 props with values of saleitem and itemchecq

Edit: based on the comment of @Icycool

G43beli
  • 3,835
  • 4
  • 21
  • 28