Sushant Torankar

Sushant Torankar

  • 1.4k
  • 220
  • 22.2k

about return type in web api

Feb 2 2023 2:48 PM

Hello,

I am working in mvc web api and following is my method:

Public HROutput CalculatePre(HRInput input)

{

HROutput objoutpt = new HROutput();

input.Policy = "2004/ABCDEF/00/000";

input.Message = "SUCCESS";

objoutpt.ActualPolicy = input.Policy;

objoutpt.Status = input.Message ;

return objoutpt ;

Here, HROutput is class with Policy and Message field and HRInput is class with ActualPolicy and Status field

In Postman I am getting Output as - 

{

"ActualPolicy " : "2004/ABCDEF/00/000",

"Status" : "SUCCESS"

}

Now, I've one more Method as -

Public clsSavePOutput SavePDetails(clsSavePInput input)

{

CalculatePre(HRInput input);

//here, I have to call above method like how we used to call void method and then I can pass parameter to return same output like above output, like - 

}

How to return or get output from CLASS return type , instead of void return type ?

 

Thank you

 


Answers (2)