Ejemplo n.º 1
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)
     });
 }
Ejemplo n.º 2
0
        public void UpdateSubscriptions()
        {
            var q = from o in OnlineRegModel.UserSelectClasses(masterorg)
                    let om = o.OrganizationMembers.SingleOrDefault(mm => mm.PeopleId == pid)
                             where om != null
                             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);
                DbUtil.Db.SubmitChanges();
            }
            foreach (var id in joins)
            {
                OrganizationMember.InsertOrgMembers(DbUtil.Db,
                                                    id, pid, MemberTypeCode.Member, DateTime.Now, null, false);
                DbUtil.Db.SubmitChanges();
                //DbUtil.Db.UpdateMainFellowship(id);
            }
        }