Beispiel #1
0
        public async Task <IActionResult> Subscribe(string userId)
        {
            _logger.LogInformation($"Subscribe action of UserController with userId = {userId}.");
            await _subscriptionService.AddSubscriptionAsync(User.Identity.Name, userId);

            return(RedirectToAction(RedirectPath.ShowAllAction, RedirectPath.UserController));
        }
Beispiel #2
0
        public void Add_Client_Subscription()
        {
            var subscription = new Subscription
            {
                ClientId        = Guid.Parse("5D502C13-8184-499E-8A02-A6C6A1C21188"),
                Active          = true,
                CreatedDate     = DateTime.Now,
                ExpireDate      = DateTime.Now.AddDays(10),
                LastUpdatedDate = null
            };

            var payment = new PayPalPayment
            {
                TransactionCode = "12345678",
                PaidDate        = DateTime.Now,
                ExpireDate      = DateTime.Now.AddDays(5),
                Total           = 10,
                TotalPaid       = 10,
                Payer           = "Tabajara Company"
            };

            subscription.Payments = new List <Payment>();
            subscription.Payments.Add(payment);

            subscriptionService.AddSubscriptionAsync(subscription);

            Assert.True(client.Subscriptions.Any());
        }
Beispiel #3
0
        /// <summary>
        /// Adds the message sender as a subscriber.
        /// </summary>
        /// <param name="message">The message being processed.</param>
        /// <returns>The response to the message.</returns>
        private async Task <BotMessage> SubscribeSenderAsync(BotMessage message)
        {
            var subscriptionKey = message.Text;
            var senderId        = message.Sender.Id;
            await _subscriptionService.AddSubscriptionAsync(senderId, subscriptionKey).ConfigureAwait(false);

            return(new BotMessage {
                Text = "Successfully subscribed."
            });
        }
Beispiel #4
0
        /// <summary>
        /// Adds the message sender as a subscriber.
        /// </summary>
        /// <param name="message">The message being processed.</param>
        /// <returns>The response to the message.</returns>
        private async Task <BotMessage> SubscribeSenderAsync(BotMessage message)
        {
            var senderId = message.Sender.Id;
            await _subscriptionService.AddSubscriptionAsync(senderId, string.Empty).ConfigureAwait(false);

            SetSubscriptionCompletedState();
            return(new BotMessage {
                Text = "Successfully subscribed."
            });
        }
Beispiel #5
0
        public async Task <IActionResult> AddClientSubscriptionAsync([FromBody] AddClientSubscriptionPost addSubscriptionRequest)
        {
            var subscription = Mapper.Map <Subscription>(addSubscriptionRequest);

            try
            {
                await subscriptionService.AddSubscriptionAsync(subscription);

                return(Ok(subscription));
            }
            catch (ClientCoreException ex) when(ex.Errors.Any(c => c.Key == ClientCoreError.ClientNotFound.Key))
            {
                return(NotFound(ClientCoreError.ClientNotFound));
            }
        }
        public async Task <ActionResult <SubscriptionDto> > PostSubscription(SubscriptionCreateDto createSubscriptionDto)
        {
            try
            {
                var inputSubscription    = _mapper.Map <SourceSubscription>(createSubscriptionDto);
                var insertedSubscription = await _subscriptionService.AddSubscriptionAsync(inputSubscription);

                var subscriptionResponse = _mapper.Map <SubscriptionDto>(insertedSubscription);
                return(Ok(subscriptionResponse));
            }
            catch (SubscriptionValidationException exception)
            {
                var innerMessage = GetInnerMessage(exception);

                return(BadRequest(innerMessage));
            }
            catch (SubscriptionServiceException exception)
            {
                return(Problem(exception.Message));
            }
        }
Beispiel #7
0
        public async Task <ActionResult <SubscriptionDto> > CreateAsync([FromBody] SubscriptionInsertDto subscription)
        {
            var createdSubscription = await subscriptionService.AddSubscriptionAsync(subscription);

            return(Created($"/api/subscriptions/{createdSubscription.Id}", createdSubscription));
        }