Skip to content

Instantly share code, notes, and snippets.

@rudylee
Last active December 17, 2015 23:49
Show Gist options
  • Select an option

  • Save rudylee/5692232 to your computer and use it in GitHub Desktop.

Select an option

Save rudylee/5692232 to your computer and use it in GitHub Desktop.
private bool ValidRequisitieMeet(int userId, int subjectId)
{
// Fetch the enrollment passed status from configuration file
var passed = TryToParse(ConfigurationManager.AppSettings.Get("EnrollmentStatusPassed"));
var requisites = (from r in _context.Requisites
where r.SubjectId == subjectId
select r);
// For the sake of readability, use traditional way
foreach (var requisite in requisites)
{
var requisiteSubjectId = requisite.SubjectId;
var enrolment = (from e in _context.Enrolments
where e.SubjectId == requisiteSubjectId
where e.UserProfileId == userId
where e.EnrolmentStatus == passed
select e).Count();
if (enrolment == 0) return false;
}
return true;
}
@xerxesb
Copy link

xerxesb commented Jun 2, 2013

return (from e in _context.Enrollments
          from r in _context.Requisites
          join e.subject_id on e.subject_id
          where r.subjectId == subectId
          and e.userProfieId == userId
          and e.EnrollemntStats == passed
          select e).Any()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment