0

I have an existing WebAPI controller method.

 [SwaggerDefaultResponse]
 [HttpGet, Route("{id:int}", Name = "GetDataId")]
 public IHttpActionResult Get(long id)
  { 
      //This method returns a full Data
  }

I have to write granular WebAPI. We are planning to have a route like below:

/V1/MYdATA/{DataId}?DataBasic=true

If DataBasic=true then I should invoke a new method to get "Basic Data" --- and if DataBasic=false then my existing Full data should be returned i.e. existing method should be invoked.

Can I get some idea for this as how to implement this in code?

Divyang Desai
  • 7,483
  • 13
  • 50
  • 76
pankaj
  • 1,030
  • 5
  • 19
  • 41

1 Answers1

0

Same controller

public IHttpActionResult Get(long id, bool DataBasic)
{ 
    if (!DataBasic)
    {
        //This method returns a full Data
    }
    else
    {
       //Method Retrieving new data
    }
}

different controller

@using (Html.BeginForm(model.Databasic ? "GetNew" : "GetFull", "ControllerName", new {id = model.Id}))
{
        <input type="submit" name="Get" />
}


public IHttpActionResult GetNew(long? id)
{ 

    //Method Retrieving new data

}

public IHttpActionResult GetFull(long id)
{ 
    //This method returns a full Data
}
Gabriel Llorico
  • 1,783
  • 1
  • 13
  • 23