Model.cs :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebApi.Models
{
public class InvoiceDetails
{
public InvoiceDetails() { }
public string InvoiceNo { get; set; }
public int InvoiceId { get; set; }
public string PartNo { get; set; }
public string PartName { get; set; }
public int NoOfPallets { get; set; }
public int PalletCapacity { get; set; }
public int Numbers { get; set; }
}
}
Controller.cs :
[HttpPost]
[ActionName("AddInvoiceDetails")]
public void insertInvoiceDetails(InvoiceUnchecked invdtls)
{
SqlConnection myConnection = new SqlConnection();
myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["ERPConnectionString"].ConnectionString;
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.CommandText = "INSERT_WAREHOUSE";
sqlCmd.Connection = myConnection;
sqlCmd.Parameters.AddWithValue("@InvoiceId", invdtls.InvoiceId);
myConnection.Open();
int rowInserted = sqlCmd.ExecuteNonQuery();
myConnection.Close();
}
I want to insert the data based on invoice id, here the data is nothing but the partno, partname, noofpallets, palletcapacity, numbers.
$scope.btntext = "Submit";
$scope.submit = function () {
var post = $http({
method: "POST",
url: "http://stagingserver:85/EBSApi/api/Warehouse/AddInvoiceDetails",
data: $scope.mydata,
dataType: 'json',
headers: { "Content-Type": "application/json" }
});
post.success(function (data,status) {
$scope.mydata.push(data);
alert('Data Submitted...!');
});
//$scope.mydata = "";
post.error(function (data,status) {
console.log($scope.Selectedinvoice.originalObject.InvoiceId);
alert('Failed');
});
}