public EntityCollectionDisplay PutEntityCollection(EntityCollectionDisplay collection)
        {
            var destination = _entityCollectionService.GetByKey(collection.Key);

            if (destination == null)
            {
                throw new NullReferenceException("Collection was not found");
            }

            destination = collection.ToEntityCollection(destination);
            _entityCollectionService.Save(destination);

            return(destination.ToEntityCollectionDisplay());
        }
        public EntityCollectionDisplay PostAddEntityCollection(EntityCollectionDisplay collection)
        {
            var ec = _entityCollectionService.CreateEntityCollection(
                collection.EntityType,
                collection.ProviderKey,
                collection.Name);

            if (collection.ParentKey != null)
            {
                ec.ParentKey = collection.ParentKey;
            }

            _entityCollectionService.Save(ec);

            return(ec.ToEntityCollectionDisplay());
        }
        public EntityCollectionDisplay PostAddEntityCollection(EntityCollectionDisplay collection)
        {
            var ec = _entityCollectionService.CreateEntityCollection(
                collection.EntityType,
                collection.ProviderKey,
                collection.Name);

            if (collection.ParentKey != null)
            {
                ec.ParentKey = collection.ParentKey;
            }

            ec.IsFilter = collection.IsFilter;
            ((EntityCollection)ec).ExtendedData = collection.ExtendedData.AsExtendedDataCollection();

            _entityCollectionService.Save(ec);

            return(ec.ToEntityCollectionDisplay());
        }