3
I have three methods being called separately on controller with JSON. Each one of them returns to me Id Name
.
I need to call these three methods in the same function in the controller. How can I join the three methods in the same function?
[HttpPost]
public ActionResult GetMessageClassByResourceByDevice(int resourceId, string deviceName)
{
return Json(EventFlow.GetMessageClassByResourceByDevice(resourceId, deviceName)
.Select(f => new { EventMessageClassId = f.Id, FullName = f.Name }));
}
[HttpPost]
public ActionResult GetMessageGroupByResourceByDevice(int resourceId, string deviceName)
{
return Json(EventFlow.GetMessageGroupByResourceByDevice(resourceId, deviceName)
.Select(f => new { EventMessageGroupId = f.Id, FullName = f.Name }));
}
[HttpPost]
public ActionResult GetMessageByResourceByDevice(int resourceId, string deviceName)
{
return Json(EventFlow.GetMessageByResourceByDevice(resourceId, deviceName)
.Select(f => new { EventMessageId = f.Id, FullName = f.Name }));
}
I’m not sure what you want, but it doesn’t look like you can improve much more than that. I think, but I could be wrong that you’re trying to do DRY where it doesn’t fit. Check this out: http://answall.com/q/120931/101 But if you explain it better, I can try to see if something can be done.
– Maniero
Each Action returns a
JsonResult
different. What’s the idea? Join all JSON into one?– Leonel Sanches da Silva