public Task ExecuteAsync(
            PostId newPostId,
            ChannelId channelId,
            ValidComment content,
            DateTime?sheduledPostDate,
            QueueId queueId,
            ValidPreviewText previewText,
            FileId previewImageId,
            IReadOnlyList <FileId> fileIds,
            int previewWordCount,
            int wordCount,
            int imageCount,
            int fileCount,
            int videoCount,
            DateTime now)
        {
            newPostId.AssertNotNull("newPostId");
            content.AssertNotNull("content");
            channelId.AssertNotNull("channelId");

            var post = new Post(
                newPostId.Value,
                channelId.Value,
                null,
                queueId == null ? (Guid?)null : queueId.Value,
                null,
                previewImageId == null ? (Guid?)null : previewImageId.Value,
                null,
                previewText == null ? null : previewText.Value,
                content.Value,
                previewWordCount,
                wordCount,
                imageCount,
                fileCount,
                videoCount,
                default(DateTime), // Live date assigned by sub-statements.
                now);

            var postFiles = fileIds.EmptyIfNull().Select(v => new PostFile(newPostId.Value, v.Value)).ToList();

            if (queueId != null)
            {
                return(this.subStatements.QueuePostAsync(post, postFiles));
            }

            return(this.subStatements.SchedulePostAsync(post, postFiles, sheduledPostDate, now));
        }
Exemplo n.º 2
0
        public async Task ExecuteAsync(UserId userId, ChannelId channelId)
        {
            userId.AssertNotNull("userId");
            channelId.AssertNotNull("channelId");

            using (var transaction = TransactionScopeBuilder.CreateAsync())
            {
                using (var connection = this.connectionFactory.CreateConnection())
                {
                    await connection.ExecuteAsync(DeleteStatement, new { ChannelId = channelId.Value, UserId = userId.Value });
                }

                await this.requestSnapshot.ExecuteAsync(userId, SnapshotType.SubscriberChannels);

                transaction.Complete();
            }
        }
Exemplo n.º 3
0
        public BlobLocation GetBlobLocation(ChannelId channelId, FileId fileId, string filePurpose)
        {
            fileId.AssertNotNull("fileId");
            filePurpose.AssertNotNull("filePurpose");

            var purpose = FilePurposes.TryGetFilePurpose(filePurpose);

            if (purpose == null)
            {
                throw new BadRequestException("Unknown file purpose.");
            }

            if (purpose.IsPublic)
            {
                return(new BlobLocation(Constants.PublicFileBlobContainerName, fileId.Value.EncodeGuid()));
            }

            channelId.AssertNotNull("channelId");
            return(new BlobLocation(this.GetBlobContainerName(channelId), fileId.Value.EncodeGuid()));
        }
Exemplo n.º 4
0
        public async Task ExecuteAsync(
            UserId userId,
            ChannelId channelId,
            ValidAcceptedChannelPrice acceptedPrice,
            DateTime now)
        {
            userId.AssertNotNull("userId");
            channelId.AssertNotNull("channelId");
            acceptedPrice.AssertNotNull("acceptedPrice");

            using (var transaction = TransactionScopeBuilder.CreateAsync())
            {
                using (var connection = this.connectionFactory.CreateConnection())
                {
                    var channelSubscription = new ChannelSubscription(
                        channelId.Value,
                        null,
                        userId.Value,
                        null,
                        acceptedPrice.Value,
                        now,
                        now);

                    const ChannelSubscription.Fields UpdateFields
                        = ChannelSubscription.Fields.AcceptedPrice
                          | ChannelSubscription.Fields.PriceLastAcceptedDate;

                    await connection.UpsertAsync(
                        channelSubscription,
                        UpdateFields);
                }

                await this.requestSnapshot.ExecuteAsync(userId, SnapshotType.SubscriberChannels);

                transaction.Complete();
            }
        }