public List<CourseTerm> GetAllCourseTerms(Site site) { var cts = from ct in site.CourseTerms select ct; return cts .OrderByDescending(ct => ct.Term.EndDate) .ThenBy(ct => ct.Name) .ToList(); }
public void DeleteSite(Site site) { dc.Courses.DeleteAllOnSubmit(site.Courses); dc.Terms.DeleteAllOnSubmit(site.Terms); dc.SiteMembers.DeleteAllOnSubmit(site.SiteMembers); dc.Invitations.DeleteAllOnSubmit(site.Invitations); dc.ProgramOutcomes.DeleteAllOnSubmit(site.ProgramOutcomes); foreach (var courseTerm in site.CourseTerms) { DeleteCourseTerm(courseTerm); } dc.Sites.DeleteOnSubmit(site); }
public void CreateSite(Profile owner, Site site) { dc.Sites.InsertOnSubmit(site); dc.SiteMembers.InsertOnSubmit(new SiteMember() { MembershipID = owner.MembershipID, Site = site, AccessLevel = 10 }); dc.SubmitChanges(); }
public static bool CheckAuthorization(HttpContext httpContext, Site site, CourseTerm courseTerm, AuthScope scope, int minLevel, int maxLevel) { AssessTrackDataRepository data = new AssessTrackDataRepository(); if (httpContext == null) { throw new ArgumentNullException("httpContext"); } IPrincipal user = httpContext.User; if (!user.Identity.IsAuthenticated) { return false; } //Get the user's profile and see if they have //the required access level Profile profile = data.GetLoggedInProfile(); switch (scope) { case AuthScope.Application: { if (profile.AccessLevel < minLevel || profile.AccessLevel > maxLevel) return false; break; } case AuthScope.Site: { SiteMember member = data.GetSiteMemberByMembershipID(site,profile.MembershipID); if (member == null || (member.AccessLevel < minLevel || member.AccessLevel > maxLevel)) return false; } break; case AuthScope.CourseTerm: { CourseTermMember member = data.GetCourseTermMemberByMembershipID(courseTerm, profile.MembershipID); if (member == null || (member.AccessLevel < minLevel || member.AccessLevel > maxLevel)) return false; } break; default: //TODO Do some logging here maybe? return false; } return true; }
public ActionResult Create(FormCollection collection) { try { Site newsite = new Site(); UpdateModel(newsite); if (ModelState.IsValid) { Profile profile = dataRepository.GetLoggedInProfile(); dataRepository.CreateSite(profile, newsite); return RedirectToAction("Index"); } else { ModelState.AddModelErrors(newsite.GetRuleViolations()); return View(); } } catch { return View(); } }
// Service methods for Site controller public SiteDetailsViewModel GetSiteDetails(Site site) { SiteDetailsViewModel details = new SiteDetailsViewModel(); var courses = GetAllCourseTerms(site); List<CourseTerm> userCTs = new List<CourseTerm>(); List<CourseTermListItem> items = new List<CourseTermListItem>(); foreach (var course in courses) { CourseTermListItem item = new CourseTermListItem(); item.CourseTerm = course; if (IsCourseTermMember(course)) { item.StudentNotEnrolled = false; userCTs.Add(course); } else { item.StudentNotEnrolled = true; } if (course.Term.EndDate >= DateTime.Now) { items.Add(item); } } details.UserCourseOfferings = userCTs; details.AllCourseOfferings = items; details.Site = site; return details; }
public CourseTermViewModel(Site site, CourseTerm courseTerm) { CourseList = new SelectList(site.Courses.ToList(), "CourseID", "Name"); TermList = new SelectList(site.Terms.ToList(), "TermID", "Name"); CourseTerm = courseTerm; }
public List<CourseTerm> GetUserCourseTerms(Site site) { return (from ct in site.CourseTerms join ctm in dc.CourseTermMembers on ct.CourseTermID equals ctm.CourseTermID where ctm.MembershipID == UserHelpers.GetCurrentUserID() select ct) .OrderByDescending(ct => ct.Term.StartDate) .ThenBy(ct => ct.Name) .ToList(); }
// This method must be thread-safe since it is called by the thread-safe OnCacheAuthorization() method. protected virtual bool AuthorizeCore(HttpContextBase httpContext, Site site, CourseTerm courseTerm) { return AuthHelper.CheckAuthorization(HttpContext.Current, site, courseTerm, scope, minLevel, maxLevel); }
public bool IsSiteMember(Site site, Profile profile) { return IsSiteMember(site, profile.MembershipID); }
public CourseTerm GetCourseTermByID(Site site, Guid id) { return (from courseterm in site.CourseTerms where courseterm.CourseTermID == id select courseterm).SingleOrDefault(); }
public SiteMemberViewModel(List<SiteMemberTable> tables, Site site) { Tables = tables; Site = site; }
public bool JoinSite(Site site) { if (IsSiteMember(site, GetLoggedInProfile())) return false; SiteMember siteMember = new SiteMember() { Site = site, Profile = GetLoggedInProfile(), AccessLevel = 1 }; dc.SiteMembers.InsertOnSubmit(siteMember); dc.SubmitChanges(); return true; }
public bool IsSiteMember(Site site, Guid id) { SiteMember sitemember = (from sm in dc.SiteMembers where sm.MembershipID == id && sm.Site == site select sm).SingleOrDefault(); return (sitemember != null); }
public CourseTermViewModel(Site site, CourseTerm courseTerm, Guid courseid, Guid termid) { CourseList = new SelectList(site.Courses.ToList(), "CourseID", "Name", courseid); TermList = new SelectList(site.Terms.ToList(), "TermID", "Name", termid); CourseTerm = courseTerm; }
//public Course GetCourseByShortName(string courseShortName) //{ // return null; //} public IEnumerable<Course> GetSiteCourses(Site site) { return site.Courses.ToList(); }
public List<CourseTerm> GetUserCourseTerms(Site site) { return (from ct in site.CourseTerms join ctm in dc.CourseTermMembers on ct.CourseTermID equals ctm.CourseTermID where ctm.MembershipID == UserHelpers.GetCurrentUserID() select ct).ToList(); }
public static string SiteLink(this HtmlHelper html, Site site, string before, string after) { if (site == null) { return string.Empty; } string sitelink = HtmlHelper.GenerateRouteLink(html.ViewContext.RequestContext, html.RouteCollection, site.Title, null, new System.Web.Routing.RouteValueDictionary( new { action = "Details", controller = "Site", siteShortName = site.ShortName }), null); string finallink = before + sitelink + after; return finallink; }
public CourseTerm GetCourseTermByShortName(Site site, string shortName) { return (from courseterm in site.CourseTerms where courseterm.ShortName == shortName select courseterm).SingleOrDefault(); }
//public SiteMember GetSiteMember public bool IsSiteMember(Site site) { return IsSiteMember(site, GetLoggedInProfile()); }