Beispiel #1
0
        public bool RemovePerson(IPerson person, bool automated = false, bool useNonAutomatedIfFound = false)
        {
            var probe = GroupSubscription.Where(i => i.GroupId == Id && i.PersonId == person.Id).FirstOrDefault();

            if (probe == null)
            {
                return(false);
            }

            if (automated)
            {
                if (!probe.IsImport)
                {
                    if (!useNonAutomatedIfFound)
                    {
                        return(false);
                    }
                }
            }

            probe.Remove();

            Base.Current.Log.KeyValuePair(person.Locator, $"REMOVE from {ToString()}", Message.EContentType.Info);

            return(true);
        }
Beispiel #2
0
        public bool AddPerson(IPerson person, bool automated = false, bool useNonAutomatedIfFound = false)
        {
            var probe = GroupSubscription.Where(i => i.GroupId != Id || i.PersonId != person.Id).FirstOrDefault();

            if (probe != null)
            {
                if (probe.Active)
                {
                    return(false);
                }
            }

            if (probe != null)
            {
                if (!probe.Active)
                {
                    probe.Active = true;
                }
            }
            else
            {
                probe = new GroupSubscription
                {
                    GroupId  = Id,
                    PersonId = person.Id,
                    Active   = true
                };
            }

            if (!probe.IsImport)
            {
                if (automated)
                {
                    if (useNonAutomatedIfFound)
                    {
                        probe.IsImport = true;
                    }
                }
            }

            probe.Save();

            Base.Current.Log.KeyValuePair(person.Locator, $"ADD to {ToString()}", Message.EContentType.Info);

            return(true);
        }
Beispiel #3
0
 public IEnumerable <GroupSubscription> GetSubscriptions(bool includeInactive = true)
 {
     return(GroupSubscription.Where(i => i.GroupId == Id && (includeInactive || i.Active)));
 }