示例#1
0
        public List <LmsCompany> GetEnabledForSynchronization(string consumerKey = null)
        {
            LmsCompany               lc  = null;
            LmsCompanySetting        lcs = null;
            OfficeHours              oh  = null;
            IList <LmsCourseMeeting> lcm = null;
            //IList<LmsUserMeetingRole> lumr = null;
            //IList<LmsUser> lu = null;
            //LmsUser u = null;
            var defaultQuery = new DefaultQueryOver <LmsCompany, int>()
                               .GetQueryOver(() => lc)
                               .Where(x => x.IsActive);

            if (!string.IsNullOrEmpty(consumerKey))
            {
                defaultQuery = defaultQuery.Where(x => x.ConsumerKey == consumerKey);
            }
            defaultQuery = defaultQuery
                           .JoinAlias(() => lc.Settings, () => lcs)
                           .Where(() => lcs.Name == LmsLicenseSettingNames.UseSynchronizedUsers && lcs.Value == "True")
                           .JoinAlias(() => lc.LmsCourseMeetings, () => lcm)
                           .JoinAlias(() => lcm.First().OfficeHours, () => oh, JoinType.LeftOuterJoin)
//                .JoinAlias(() => lcm.First().MeetingRoles, () => lumr)
//                .Fetch(x => x.Settings).Eager
                           .Fetch(x => x.LmsCourseMeetings).Eager
                           .Fetch(x => x.LmsCourseMeetings.First().OfficeHours).Eager
//                .Fetch(x => x.LmsCourseMeetings.First().MeetingRoles).Eager
                           .Fetch(x => x.AdminUser).Eager
                           .TransformUsing(Transformers.DistinctRootEntity);
            return(this.Repository.FindAll(defaultQuery).ToList());
        }
示例#2
0
        public void UpdateCompanySetting(LmsCompany lmsCompany, string settingName, string settingValue)
        {
            if ((lmsCompany.Id == default(int)) && (lmsCompany.Settings == null))
            {
                lmsCompany.Settings = new List <LmsCompanySetting>();
            }

            LmsCompanySetting setting = lmsCompany.Settings.SingleOrDefault(x => string.Compare(x.Name, settingName, true) == 0);

            if (setting == null)
            {
                lmsCompany.Settings.Add(new LmsCompanySetting
                {
                    LmsCompany = lmsCompany,
                    Name       = settingName,
                    Value      = settingValue,
                });
            }
            else
            {
                setting.Value = settingValue;
            }
        }