Пример #1
0
 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();
 }
Пример #2
0
 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);
 }
Пример #3
0
        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();
        }
Пример #4
0
 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;
 }
Пример #5
0
        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();
            }
        }
Пример #6
0
        // 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;
        }
Пример #7
0
 public CourseTermViewModel(Site site, CourseTerm courseTerm)
 {
     CourseList = new SelectList(site.Courses.ToList(), "CourseID", "Name");
     TermList = new SelectList(site.Terms.ToList(), "TermID", "Name");
     CourseTerm = courseTerm;
 }
Пример #8
0
 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();
 }
Пример #9
0
 // 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);
 }
Пример #10
0
 public bool IsSiteMember(Site site, Profile profile)
 {
     return IsSiteMember(site, profile.MembershipID);
 }
Пример #11
0
 public CourseTerm GetCourseTermByID(Site site, Guid id)
 {
     return (from courseterm in site.CourseTerms
             where courseterm.CourseTermID == id
             select courseterm).SingleOrDefault();
 }
Пример #12
0
 public SiteMemberViewModel(List<SiteMemberTable> tables, Site site)
 {
     Tables = tables;
     Site = site;
 }
Пример #13
0
 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;
 }
Пример #14
0
 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);
 }
Пример #15
0
 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;
 }
Пример #16
0
 //public Course GetCourseByShortName(string courseShortName)
 //{
 //    return null;
 //}
 public IEnumerable<Course> GetSiteCourses(Site site)
 {
     return site.Courses.ToList();
 }
Пример #17
0
 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();
 }
Пример #18
0
        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;
        }
Пример #19
0
 public CourseTerm GetCourseTermByShortName(Site site, string shortName)
 {
     return (from courseterm in site.CourseTerms
             where courseterm.ShortName == shortName
             select courseterm).SingleOrDefault();
 }
Пример #20
0
 //public SiteMember GetSiteMember
 public bool IsSiteMember(Site site)
 {
     return IsSiteMember(site, GetLoggedInProfile());
 }