Prakash

Prakash

  • NA
  • 258
  • 78.5k

mvc

May 22 2015 4:38 AM
hello this is the piece code (below) i want to calculate progress of chapter and subject...in this code use random method...but i want do manual...plz help..and give me sample code if possible....
thank u
 
 
public ActionResult GetSubjectProgress(string id)
{

Guid stdid = new Guid(id);
var subjects = from s in db.Subjects
where s.Standard == stdid
select s;



List<SubjectProgress> subjectPropgress = new List<SubjectProgress>();
Random rnd = new Random();

foreach (Subject s in subjects)
{
SubjectProgress subProg = new SubjectProgress();
subProg.id = s.Id;
subProg.name = s.Name;
subProg.chapters = new List<ChapterProgress>();

foreach (Chapter c in s.Chapters)
{
ChapterProgress chptProg = new ChapterProgress();
chptProg.id = c.Id;
chptProg.name = c.Name;
chptProg.progress = rnd.Next(1, 100);

subProg.chapters.Add(chptProg);
}

subProg.progress = rnd.Next(1, 100);

subjectPropgress.Add(subProg);
}

return View(subjectPropgress);

}


Answers (5)