Esempio n. 1
0
        public Task <bool> IsWriteAllowedAsync(UserId requester, Shared.QueueId queueId)
        {
            requester.AssertNotNull("requester");
            queueId.AssertNotNull("queueId");

            return(this.queueOwnership.IsOwnerAsync(requester, queueId));
        }
Esempio n. 2
0
        public async Task AssertWriteAllowedAsync(UserId requester, Shared.QueueId queueId)
        {
            requester.AssertNotNull("requester");
            queueId.AssertNotNull("queueId");

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

            if (!isWriteAllowed)
            {
                throw new UnauthorizedException("Not allowed to write to collection. {0} {1}", requester, queueId);
            }
        }
Esempio n. 3
0
        public async Task <bool> IsOwnerAsync(UserId userId, Shared.QueueId queueId)
        {
            userId.AssertNotNull("userId");
            queueId.AssertNotNull("queueId");

            using (var connection = this.connectionFactory.CreateConnection())
            {
                return(await connection.ExecuteScalarAsync <bool>(
                           Sql,
                           new
                {
                    QueueId = queueId.Value,
                    CreatorId = userId.Value
                }));
            }
        }
        public async Task <DateTime> ExecuteAsync(Shared.QueueId queueId, DateTime now)
        {
            queueId.AssertNotNull("queueId");
            now.AssertUtc("now");

            var parameters = new
            {
                QueueId = queueId.Value,
                Now     = now
            };

            using (var connection = this.connectionFactory.CreateConnection())
            {
                var result = await connection.ExecuteScalarAsync <DateTime>(Sql, parameters);

                return(DateTime.SpecifyKind(result, DateTimeKind.Utc));
            }
        }