public BaseCollection <NewsletterSubscriber> GetNewsletterRecipients(Guid newsletterId, string[] NewsletterGroups, bool sendToNewSubscribers)
        {
            int AvailableMailings = -1;

            if (SessionObject.CurrentLicense.MaxNumberOfNewsletterMailings != null)
            {
                AvailableMailings = (int)SessionObject.CurrentLicense.MaxNumberOfNewsletterMailings - BaseCollection <NewsletterMailing> .Get("FK_Site = '" + SessionObject.CurrentSite.ID.ToString() + "'").Count();
            }

            string groupIDs = "";

            foreach (string groupID in NewsletterGroups)
            {
                groupIDs += "'" + groupID + "', ";
            }
            groupIDs     = groupIDs.Substring(0, groupIDs.Length - 2);
            string where = " EXISTS (SELECT * FROM NewsletterGroupSubscriber WHERE `UnsubscribeDate` IS NULL AND FK_NewsletterSubscriber = NewsletterSubscriber.ID AND FK_NewsletterGroup IN (" + groupIDs + ") AND Confirmed = 1)";
            if (sendToNewSubscribers)
            {
                where = " EXISTS (SELECT * FROM NewsletterGroupSubscriber WHERE `UnsubscribeDate` IS NULL AND FK_NewsletterSubscriber = NewsletterSubscriber.ID AND FK_NewsletterGroup IN (" + groupIDs + ") AND Confirmed = 1 AND NOT EXISTS(SELECT * FROM newslettermailing WHERE FK_Newsletter = '" + newsletterId.ToString() + "' AND FK_NewsletterSubscriber = NewsletterSubscriber.ID))";
            }
            BaseCollection <NewsletterSubscriber> subscribers = BaseCollection <NewsletterSubscriber> .Get(where);

            if (AvailableMailings != -1 && subscribers.Count() > AvailableMailings)
            {
                throw new Exception("Om de nieuwsbrief naar deze maillijst te versturen zijn: " + subscribers.Count().ToString() + " mailingen vereist. \r\n U heeft nog: " + AvailableMailings.ToString() + " mailingen beschikbaar.");
            }
            return(subscribers);
        }
    public void RemoveAt()
    {
        BaseCollection <int> collection = new BaseCollection <int>(new [] { 1, 2, 3 });

        collection.RemoveAt(2);
        collection.RemoveAt(1);
        Assert.AreEqual(1, collection.Count());
        Assert.AreEqual(1, collection[0]);
    }
    public void ProcessParametrizedConstructor()
    {
        BaseCollection <int> collection = new BaseCollection <int>(new [] { 1, 2, 3 });

        Assert.AreEqual(3, collection.Count());
        Assert.AreEqual(1, collection[0]);
        Assert.AreEqual(2, collection[1]);
        Assert.AreEqual(3, collection[2]);
    }
    public void Set()
    {
        BaseCollection <int> collection = new BaseCollection <int>( );

        collection.Set(new [] { 1, 2, 3 });
        Assert.AreEqual(3, collection.Count());
        Assert.AreEqual(1, collection[0]);
        Assert.AreEqual(2, collection[1]);
        Assert.AreEqual(3, collection[2]);
    }
    public void BeEmptyOnDefaultCreation()
    {
        BaseCollection <int> collection = new BaseCollection <int>();

        Assert.AreEqual(0, collection.Count());
    }
        public bool Exists(string id)
        {
            var mongoQuery = Query <T> .EQ(u => u.Id, id);

            return(BaseCollection.Count(mongoQuery) > 0);
        }