オブジェクトの配列をAngularで生成し、C#コントローラに送信します。これどうやってするの?AngularフロントエンドからC#バックエンドへオブジェクトの配列を渡す方法
これは、オブジェクトの配列を生成するためのコードです。
var addObjectToArray = function (id, price, quantity, tax) {
$scope.element = {
prodId: id,
patientId: $state.params.patientId,
clinicId: $cookies.get("clinicId"),
user: authService.authentication.userName,
price: price,
quantity: quantity,
tax: tax,
subtotal: price * quantity,
total: price * quantity + tax
};
$scope.productsArray.push({ product: $scope.element });
}
これはC#コントローラです。 C#コントローラの2番目のパラメータとしてオブジェクトの配列を渡すにはどうすればよいですか?助けのための
[HttpPost]
[Route("... the route ...")]
[ResponseType(typeof(int))]
public IHttpActionResult InsertNewProductTotal(int clinicId) // << HOW CAN I GET THE ARRAY OF OBJECTS HERE ??? >>
{
var newAttorney = _productSaleLogic.InsertNewProductTotal(clinicId, productsList);
return Created(Request.RequestUri.ToString(), newAttorney);
}
ありがとう!
ような何かを行うことができます(タイプのIEnumerableの)Idプロパティとコレクションが含まれますViewModelに(クラス)プロパティを作成します。 – shammelburg