public ActionResult FormList(string id, string page) { int realId = Convert.ToInt32(id); DbDataContext db = new DbDataContext(); CForm cf = db.Forms.FirstOrDefault(s => s.Id == realId); List <String> headerList = cf.ViewProperties.Split(',').ToList(); ViewBag.HeaderList = headerList; ViewBag.PageHeader = cf.Name; List <FormViewListModel> mdList = new List <FormViewListModel>(); var cfList = db.FormLists.Where(h => h.FormId == realId && h.ActiveStatus == EActiveStatus.Active); ViewBag.ListCount = cfList.Count(); ViewBag.CurrentPage = page; int intPage = Convert.ToInt32(page); foreach (var h in cfList.OrderByDescending(g => g.Id).Skip((intPage - 1) * PageSize).Take(PageSize)) { FormViewListModel md = new FormViewListModel(); md.Parameters = new List <KeyValuePair <string, string> >(); dynamic d = JObject.Parse(h.JsonData); foreach (var item in headerList) { md.Parameters.Add(new KeyValuePair <string, string>(item, d[item].ToString())); } md.FormListId = h.Id; mdList.Add(md); } return(View(mdList)); }
public ActionResult FormDetail(string id) { int realId = Convert.ToInt32(id); DbDataContext db = new DbDataContext(); CFormList fList = db.FormLists.FirstOrDefault(f => f.Id == realId); ViewBag.FormName = fList.Form.Name; FormViewListModel md = new FormViewListModel(); md.Parameters = new List <KeyValuePair <string, string> >(); dynamic d = JObject.Parse(fList.JsonData); foreach (var item in fList.Form.Properties.Split(',').ToList()) { md.Parameters.Add(new KeyValuePair <string, string>(item, d[item].ToString())); } md.FormListId = fList.Id; return(View(md)); }