服务器返回json
public JsonResult ListCompanyRepresentatives(int id)
{
var party = _partyRepository.GetCompanyById(id);
var names = from n in party.Representatives
orderby n.ValidTo, n.RepresentativeParty.DisplayName
select new
{
Id = n.Id.ToString(),
Name = n.RepresentativeParty.DisplayName,
Role = n.Role ?? string.Empty,
Context = n.Context ?? string.Empty,
ValidFrom = n.ValidFrom.ToShortDateString(),
ValidTo = n.ValidTo.ToShortDateString()
};
var rows = names.ToArray();
var data = new
{
total = rows.Count(),
page = 1,
records = rows.Count(),
rows = rows
};
return Json(data, JsonRequestBehavior.AllowGet);
}
{
var party = _partyRepository.GetCompanyById(id);
var names = from n in party.Representatives
orderby n.ValidTo, n.RepresentativeParty.DisplayName
select new
{
Id = n.Id.ToString(),
Name = n.RepresentativeParty.DisplayName,
Role = n.Role ?? string.Empty,
Context = n.Context ?? string.Empty,
ValidFrom = n.ValidFrom.ToShortDateString(),
ValidTo = n.ValidTo.ToShortDateString()
};
var rows = names.ToArray();
var data = new
{
total = rows.Count(),
page = 1,
records = rows.Count(),
rows = rows
};
return Json(data, JsonRequestBehavior.AllowGet);
}