DATABASE:
create database api_consumtion
use api_consumtion
create table tbl_teacher
(
t_id int primary key identity,
t_name varchar(50) not null
)
create table tbl_student
(
std_id int primary key identity,
std_name varchar(50) not null,
std_gender varchar(8) not null,
std_age int,
std_class int,
t_id_fk int foreign key references tbl_teacher(t_id)
)
select * from tbl_student
NEWAPI CONTOLLER:
api_consumtionEntities db = new api_consumtionEntities();
[System.Web.Http.HttpGet]
public IHttpActionResult Action()
{
List<tbl_student> obj = db.tbl_student.ToList();
return Ok(obj);
}
[System.Web.Http.HttpGet]
public IHttpActionResult Action(int id)
{
var obj = db.tbl_student.Where(model => model.std_id == id).FirstOrDefault();
return Ok(obj);
}
Comments
Post a Comment