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
Naimish MakwanaPosted Feb 2, 2023, 3:56 PM
Hello Sushant,
Your can use AutoMapper for this. Please refer below article.
https://www.c-sharpcorner.com/article/what-is-automapper-in-asp-net-core/
Thanks
Naimish Makwana
Pasang TamangPosted Feb 2, 2023, 3:42 PM
Hi,
Please check below link to get idea about how Web API controller has to be
https://dotnettutorials.net/lesson/creating-web-api-application/
Regards,
Pasang