1. Enable tuple
Install System.Tuples from NuGet Package Manager
2. c#7 new tuple return
//type2
Install System.Tuples from NuGet Package Manager
2. c#7 new tuple return
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebApplication8.Models;
namespace WebApplication8.Controllers
{
public class home_Controller : ApiController
{
//type1
//type1
[HttpGet]
public (int st, string msg, List<Employee> emp_list)
Get_Data([FromUri] Employee d)
{
int status = 1;
string message = "Success";
List<Employee> employee_list
= new List<Employee>() { new Employee { Address = "Agra", Emp_Name = "Rinkesh", Mobile =
987998, Srno = 1 }
,new Employee { Address="Agra",Emp_Name="Manish",Mobile=987998,Srno=2 }
,new Employee { Address="Sandeep",Emp_Name="Mathura",Mobile=5555,Srno=3}
};
return (st: status, msg: message, emp_list: employee_list);
}
//type2
[HttpGet]
public (int st, string msg, List<Employee> emp_list)
Get_Data([FromUri] Employee d)
{
int status = 1;
string message = "Success";
List<Employee> employee_list
= new List<Employee>() { new Employee { Address = "Agra", Emp_Name = "Rinkesh", Mobile =
987998, Srno = 1 }
,new Employee { Address="Agra",Emp_Name="Manish",Mobile=987998,Srno=2 }
,new Employee { Address="Sandeep",Emp_Name="Mathura",Mobile=5555,Srno=3}
};
return (status, message, employee_list);
}
}
}
No comments:
Post a Comment