Controller Side Implementation
[OutputCache(Duration = 0)]
public async Task<JsonResult> BindAll()
{
var Task1
= _res.Task1().ConfigureAwait(false);
var Task2
= _res.Task2().ConfigureAwait(false);
var Task3
= _res.Task3().ConfigureAwait(false);
var resTask1
= (await Task1).OrderBy(t
=> t.Id).ToList();
var resTask2
= (await Task2).OrderBy(t
=> t.Id).ToList();
var resTask3
= (await Task3).OrderBy(t
=> t.Id).ToList();
return Json(new
{
resTask1,
resTask2,
resTask3
}, JsonRequestBehavior.AllowGet);
}
Web.API Implementation
public async Task<List<ClassName>> GetAll(int value)
{
var apiUrl = string.Format("{0}/api/ControllerName/GetAll/{1}", _ServiceName,
value);
using (var client
= new HttpClient())
{
var response = await client.GetAsync(apiUrl);
if
(!response.IsSuccessStatusCode)
return null;
return await
response.Content.ReadAsAsync<List<ClassName>>();
}
}
[Route("GetAll/{value}")]
public IHttpActionResult GetAll(int value)
{
var results = _service.GetAll(value);
if (results
== null || results.Count
== 0)
return NotFound();
else
return Ok(results);
}
public async Task<List<ClassName>> GetAllValues(Model objFilter)
{
var apiUrl = string.Format("{0}/api/ControllerName/GetAllValues/", _ServiceName);
using (var client
= new HttpClient())
{
var response = await client.PostAsJsonAsync(apiUrl, objFilter);
if
(!response.IsSuccessStatusCode)
return null;
return await
response.Content.ReadAsAsync<List<ClassName>>();
}
}
[HttpPost]
[Route("GetAllValues")]
public IHttpActionResult GetAllValues(Model objFilter)
{
var results = _service.GetAllValues(objFilter);
if (results
== null || results.Count
== 0)
return
NotFound();
else
return Ok(results);
}