public IActionResult Get() { var states = stateServ.GetAsync().Result; var depts = deptServ.GetAsync().Result; // anonymous types C# 3.0 // var response = new { states = states, depts = depts }; var response = new StateDept() { States = states.ToList(), Depts = depts.ToList() }; return(Ok(response)); }
public IActionResult Post(StateDept stateDept) { try { var respState = stateServ.CreateAsync(stateDept.State).Result; var respDept = deptServ.CreateAsync(stateDept.Dept).Result; var response = new { rState = respState, rDept = respDept }; return(Ok(response)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }