0

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);
        }

    }


    }
5
  • @RahulSharma yes you are right Commented Aug 21, 2019 at 12:41
  • @RahulSharma i want the TransactionId to Scdid Commented Aug 21, 2019 at 12:43
  • @RahulSharma actually my API is running when cheking in postman i post values DB and to and work fine but same time it it could not pass the output paramert to the api Commented Aug 22, 2019 at 10:18
  • Let us continue this discussion in chat. Commented Aug 22, 2019 at 10:41
  • Did you get this resolved? Commented Aug 24, 2019 at 7:52

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.