Prakash

Prakash

  • NA
  • 258
  • 77.6k

MVC - display data using ViewBag

May 7 2015 1:49 AM

hello...i am developing mvc5 base application.I want to display this type of data by using "ViewBag" ?
 pl help me..thank u.
below is th piece of code..
public ActionResult GetQuestionsCountAndCurrent(Guid id)
{
var question = from x in db.Questions
where x.Chapter.Equals(id)
select x.Question1;

int totalQuestions = question.Count();

Guid userId = new Guid("FAA81C69-2D14-49EA-8C4C-6A440B2D78F6"); // get current user

var readQuestions = from y in db.UserProgresses
where y.Chapter.Equals(id) & y.UserID.Equals(userId)
select y.ReadQuestions;

int totalReadQuestions = 0;

foreach (string rdq in readQuestions)
{
totalReadQuestions = rdq.Split('#').Count();
}

string progress = totalReadQuestions.ToString() + "/" + totalQuestions.ToString();
return View(progress);
}


Answers (1)