Exemplo n.º 1
0
        public Task <bool> IsWriteAllowedAsync(UserId requester, Shared.ChannelId channelId)
        {
            requester.AssertNotNull("requester");
            channelId.AssertNotNull("channelId");

            return(this.channelOwnership.IsOwnerAsync(requester, channelId));
        }
Exemplo n.º 2
0
        public async Task AssertWriteAllowedAsync(UserId requester, Shared.ChannelId channelId)
        {
            requester.AssertNotNull("requester");
            channelId.AssertNotNull("channelId");

            var isWriteAllowed = await this.IsWriteAllowedAsync(requester, channelId);

            if (!isWriteAllowed)
            {
                throw new UnauthorizedException("Not allowed to write to channel. {0} {1}", requester, channelId);
            }
        }
        public DeleteChannelCommand(
            Fifthweek.Api.Identity.Shared.Membership.Requester requester,
            Fifthweek.Api.Channels.Shared.ChannelId channelId)
        {
            if (requester == null)
            {
                throw new ArgumentNullException("requester");
            }

            if (channelId == null)
            {
                throw new ArgumentNullException("channelId");
            }

            this.Requester = requester;
            this.ChannelId = channelId;
        }
        public CreateChannelCommand(
            Fifthweek.Api.Identity.Shared.Membership.Requester requester,
            Fifthweek.Api.Channels.Shared.ChannelId newChannelId,
            Fifthweek.Api.Blogs.Shared.BlogId blogId,
            Fifthweek.Api.Channels.Shared.ValidChannelName name,
            Fifthweek.Api.Channels.Shared.ValidChannelPrice price,
            System.Boolean isVisibleToNonSubscribers)
        {
            if (requester == null)
            {
                throw new ArgumentNullException("requester");
            }

            if (newChannelId == null)
            {
                throw new ArgumentNullException("newChannelId");
            }

            if (blogId == null)
            {
                throw new ArgumentNullException("blogId");
            }

            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            if (price == null)
            {
                throw new ArgumentNullException("price");
            }

            if (isVisibleToNonSubscribers == null)
            {
                throw new ArgumentNullException("isVisibleToNonSubscribers");
            }

            this.Requester    = requester;
            this.NewChannelId = newChannelId;
            this.BlogId       = blogId;
            this.Name         = name;
            this.Price        = price;
            this.IsVisibleToNonSubscribers = isVisibleToNonSubscribers;
        }
        public OrphanedFileData(
            Fifthweek.Api.FileManagement.Shared.FileId fileId,
            Fifthweek.Api.Channels.Shared.ChannelId channelId,
            System.String purpose)
        {
            if (fileId == null)
            {
                throw new ArgumentNullException("fileId");
            }

            if (purpose == null)
            {
                throw new ArgumentNullException("purpose");
            }

            this.FileId    = fileId;
            this.ChannelId = channelId;
            this.Purpose   = purpose;
        }
Exemplo n.º 6
0
        public async Task <bool> IsOwnerAsync(UserId userId, Shared.ChannelId channelId)
        {
            userId.AssertNotNull("userId");
            channelId.AssertNotNull("channelId");

            using (var connection = this.connectionFactory.CreateConnection())
            {
                return(await connection.ExecuteScalarAsync <bool>(
                           @"IF EXISTS(SELECT *
                                FROM        Channels channel
                                INNER JOIN  Blogs blog
                                    ON      channel.BlogId  = blog.Id
                                WHERE       channel.Id              = @ChannelId
                                AND         blog.CreatorId  = @CreatorId)
                        SELECT 1 AS FOUND
                    ELSE
                        SELECT 0 AS FOUND",
                           new
                {
                    ChannelId = channelId.Value,
                    CreatorId = userId.Value
                }));
            }
        }