Asim Jena

Asim Jena

  • NA
  • 81
  • 30.1k

how to pass more than one parameter in web api

Aug 17 2018 3:43 AM
[Route("GetSubProduct/{paramone}/{paramtwo}")]
[HttpGet]
public HttpResponseMessage GetProductById(GetSubProduct request, [FromUri]int Ccode, [FromUri]int Pcode)
{
if (request == null)
{
request = new GetSubProduct();
}
if (ModelState.IsValid)
{
DataTable dt = new DataTable();
dt = new CategoryAppService().GetSubProduct(request,Ccode, Pcode);
if (dt != null && dt.Rows.Count > 0)
{
var listvalue = (from p in dt.AsEnumerable()
select new
{
sub_code = p.Field<int>("SUB_CODE"),
ctg_code = p.Field<int>("CTG_CODE"),
prd_code = p.Field<int>("PRD_CODE"),
sub_name = p.Field<string>("SUB_NAME"),
sub_img = p.Field<string>("SUB_IMG"),
quantity = p.Field<int>("QUANTITY"),
offer_price = p.Field<decimal>("OFFER_PRICE"),
sale_price = p.Field<decimal>("SALE_PRICE"),
flavour_type = p.Field<int>("FLAVOUR_TYPE"),
sub_type=p.Field<string>("SUB_TYPE"),
size=p.Field<string>("SIZE"),
description=p.Field<string>("DESCRIPTION")
}).ToList();
return Request.CreateResponse(HttpStatusCode.OK, listvalue);
}
else
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
}
}
else
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
}
}

Answers (4)