Exemplo n.º 1
0
        public IEnumerable <OrgSub> FetchSubs()
        {
            IEnumerable <OrgSub> q = null;

            if (masterorgid != null)
            {
                q = from o in OnlineRegModel.UserSelectClasses(masterorg)
                    select new OrgSub
                {
                    OrgId       = o.OrganizationId,
                    Name        = o.OrganizationName,
                    Description = o.Description,
                    Checked     = o.OrganizationMembers.Any(om => om.PeopleId == pid)
                }
            }
            ;
            else
            {
                q = from o in DbUtil.Db.Organizations
                    where o.DivOrgs.Any(dd => dd.DivId == divid)
                    where o.RegistrationTypeId == RegistrationTypeCode.ManageSubscriptions
                    select new OrgSub
                {
                    OrgId       = o.OrganizationId,
                    Name        = o.OrganizationName,
                    Description = o.Description,
                    Checked     = o.OrganizationMembers.Any(om => om.PeopleId == pid)
                }
            };
            return(q);
        }
Exemplo n.º 2
0
 public IEnumerable <OrgSub> FetchSubs()
 {
     return(from o in OnlineRegModel.UserSelectClasses(masterorg)
            select new OrgSub
     {
         OrgId = o.OrganizationId,
         Name = o.OrganizationName,
         Description = o.Description,
         Checked = o.OrganizationMembers.Any(om => om.PeopleId == pid)
     });
 }
Exemplo n.º 3
0
        public void UpdateSubscriptions()
        {
            IEnumerable <OrganizationMember> q;

            if (masterorgid != null)
            {
                q                   = from o in OnlineRegModel.UserSelectClasses(masterorg)
                             let om = o.OrganizationMembers.SingleOrDefault(mm => mm.PeopleId == pid)
                                      where om != null
                                      select om;
            }
            else
            {
                q = from om in DbUtil.Db.OrganizationMembers
                    where om.Organization.DivOrgs.Any(dd => dd.DivId == divid)
                    where om.Organization.RegistrationTypeId == RegistrationTypeCode.ManageSubscriptions
                    where om.PeopleId == pid
                    select om;
            }
            var current = q.ToList();

            if (Subscribe == null)
            {
                Subscribe = new int[] { }
            }
            ;

            var drops = from om in current
                        join id in Subscribe on om.OrganizationId equals id into j
                        from id in j.DefaultIfEmpty()
                        where id == 0
                        select om;

            var joins = from id in Subscribe
                        join om in current on id equals om.OrganizationId into j
                        from om in j.DefaultIfEmpty()
                        where om == null
                        select id;

            foreach (var om in drops)
            {
                om.Drop(DbUtil.Db, addToHistory: true);
                DbUtil.Db.SubmitChanges();
            }
            foreach (var id in joins)
            {
                OrganizationMember.InsertOrgMembers(DbUtil.Db,
                                                    id, pid, 220, DateTime.Now, null, false);
                DbUtil.Db.SubmitChanges();
                //DbUtil.Db.UpdateMainFellowship(id);
            }
        }