Reputation: 381
Here I retrieve the output parameter from a stored procedure in Entity Framework(EDMX)
(the out parameter is TransactionId) here i want to transfer the value TransactionId to Scdid(in the next post method) how to get the TransactionId = Scdid in the controller
my API code is
public class StockcountheaderController : ApiController
{
private adminv2Entities enqentities = new adminv2Entities();
[HttpPost]
private void Stock([FromBody] List<spGetNewStockCountHeader_Result> jsonvalues)
{
foreach (spGetNewStockCountHeader_Result Datastock in jsonvalues)
{
ObjectParameter TransactionId = new
ObjectParameter("TransactionId", typeof(Int32));
spGetNewStockCountHeader_Result Stockobject = new
spGetNewStockCountHeader_Result();
Stockobject.UserID = Datastock.UserID;
Stockobject.created = Datastock.created;
Stockobject.CompanyID = Datastock.CompanyID;
Stockobject.modified = Datastock.modified;
Stockobject.modifieduserid = Datastock.modifieduserid;
Stockobject.confirm = Datastock.confirm;
Stockobject.ShopId = Datastock.ShopId;
enqentities.spGetNewStockCountHeader(Datastock.UserID,
Datastock.created,
Datastock.CompanyID, Datastock.modified,
Datastock.modifieduserid, Datastock.confirm,
Datastock.ShopId, TransactionId);
}
}
}
Upvotes: 0
Views: 1048
Reputation: 8302
After a detailed discussion on the problem, the OUTPUT parameter was not being returned correctly from the stored procedure. The final solution to the above question required changes to the code:
[HttpPost]
private IActionResult Stock([FromBody] List<spGetNewStockCountHeader_Result> jsonvalues)
{
ObjectParameter TransactionId = new ObjectParameter("TransactionId", typeof(Int32));
foreach (spGetNewStockCountHeader_Result Datastock in jsonvalues)
{
spGetNewStockCountHeader_Result Stockobject = new spGetNewStockCountHeader_Result();
Stockobject.UserID = Datastock.UserID;
Stockobject.created = Datastock.created;
Stockobject.CompanyID = Datastock.CompanyID;
Stockobject.modified = Datastock.modified;
Stockobject.modifieduserid = Datastock.modifieduserid;
Stockobject.confirm = Datastock.confirm;
Stockobject.ShopId = Datastock.ShopId;
enqentities.spGetNewStockCountHeader(Datastock.UserID, Datastock.created, Datastock.CompanyID, Datastock.modified, Datastock.modifieduserid, Datastock.confirm,Datastock.ShopId, TransactionId);
}
return Ok(new { data = TransactionId.Value});
}
Once you get the TransactionId
value in your Angular application, you can use that value to send it to the next method either as a parameter in the query string or in the POST body.
Upvotes: 2