Esempio n. 1
0
        public async Task <Result> AddRelease(Release release)
        {
            try
            {
                await _dbContext.Releases.AddAsync(release);

                await _dbContext.SaveChangesAsync();

                return(Result.Success());
            }
            catch (Exception e)
            {
                _logger.LogInformation("Adding release with releaseNumber {releaseNumber} for {mediaName} failed due to: {exceptionMessage}. ", release.ReleaseNumber.ToString(), release.Media.MediaName, e.Message);
                return(Result.Failure("Adding the release to the database failed."));
            }
        }
Esempio n. 2
0
        public async Task <Result> AddSubscription(Subscription subscription, CancellationToken cancellationToken)
        {
            try
            {
                if (!await SubscriptionExists(subscription.MediaId, subscription.NotificationEndpointId, cancellationToken))
                {
                    await _dbContext.Subscriptions.AddAsync(subscription, cancellationToken);

                    await _dbContext.SaveChangesAsync(cancellationToken);
                }
                return(Result.Success());
            }
            catch (Exception e)
            {
                _logger.LogInformation(
                    "Adding subscription for notificationEndpoint with id {id} for media with id {mediaId} failed due to: {exceptionMessage}. ",
                    subscription.NotificationEndpointId,
                    subscription.MediaId,
                    e.Message);
                return(Result.Failure("Adding the subscription to the database failed."));
            }
        }
Esempio n. 3
0
        public async Task <Result> AddSubscription(Subscription subscription)
        {
            try
            {
                if (!await SubscriptionExists(subscription.Media.Id, subscription.NotificationEndpoint.Id))
                {
                    await _dbContext.Subscriptions.AddAsync(subscription);

                    await _dbContext.SaveChangesAsync();
                }

                return(Result.Success());
            }
            catch (Exception e)
            {
                _logger.LogInformation(
                    "Adding subscription for notificationEndpoint with identifier {identifier} for media {mediaName} failed due to: {exceptionMessage}. ",
                    subscription.NotificationEndpoint.Identifier,
                    subscription.Media.MediaName,
                    e.Message);
                return(Result.Failure("Adding the subscription to the database failed."));
            }
        }
Esempio n. 4
0
        public async Task <Result> AddNotificationEndpoint(NotificationEndpoint notificationEndpoint, CancellationToken cancellationToken)
        {
            try
            {
                if (!await NotificationEndpointExists(notificationEndpoint.Identifier, cancellationToken))
                {
                    await _dbContext.AddAsync(notificationEndpoint, cancellationToken);

                    await _dbContext.SaveChangesAsync(cancellationToken);
                }

                return(Result.Success());
            }
            catch (Exception e)
            {
                _logger.LogInformation("Adding notificationEndpoint with identifier {identifier} failed due to: {exceptionMessage}. ",
                                       notificationEndpoint.Identifier,
                                       e.Message);
                return(Result.Failure("Adding the notificationEndpoint to the database failed."));
            }
        }