public ActionResult List(int page, int rows, string sidx, string sord) { var questions = new PollQuestionService().GetAllItems().ToList(); var model = from entity in questions.AsQueryable() select new { ProductID = 1, ProductName = entity.Question, UnitPrice = 10, Discontinued = "" }; return Json(model.ToJqGridData(page, rows, null, "", new[] { "ProductName", "UnitPrice" }), JsonRequestBehavior.AllowGet); }
public ActionResult GetQuestions(int page, int rows, string sidx, string sord, int? PollId) { var polls = new PollQuestionService().List(PollId.Value); var totalResponse = new PollQuestionService().CountResponses(PollId.Value); var model = from entity in polls.OrderBy(sidx + " " + sord) select new { Id = entity.Id, Question = entity.Question, Responses = entity.Responses, PollId = entity.PollId, Percent = string.Format("{0:#.00%}",((float) entity.Responses)/totalResponse) }; return Json(model.ToJqGridData(page, rows, null, "", new[] { "Question", "Responses" }), JsonRequestBehavior.AllowGet); }
public PublicPollViewData(int id) { ActivePoll = new PollService().GetItem(id); Questions = new PollQuestionService().GetQuestionByPoll(ActivePoll); Calculate(); }