示例#1
0
        public async Task <Subscriptions> CreateSubscriptionAsync(MessageModel messageModel, ILogger logger)
        {
            logger.LogInformation("Creating Subscription Async");

            if (messageModel == null)
            {
                return(null);
            }

            var subscription = new Subscriptions
            {
                SubscriptionId   = Guid.NewGuid(),
                CustomerId       = messageModel.CustomerGuid.GetValueOrDefault(),
                TouchPointId     = messageModel.TouchpointId,
                Subscribe        = true,
                LastModifiedDate = messageModel.LastModifiedDate,
            };

            if (!messageModel.LastModifiedDate.HasValue)
            {
                subscription.LastModifiedDate = DateTime.Now;
            }

            logger.LogInformation("Creating Subscription In DB");
            var response = await _dbProvider.CreateSubscriptionsAsync(subscription);

            return(response.StatusCode == HttpStatusCode.Created ? (dynamic)response.Resource : (Guid?)null);
        }