Ejemplo n.º 1
0
        public async Task UserData_Information_SubscriptionTests()
        {
            //ensure users with no subscriptions don't error out
            var noSubUserName = "******";

            VoatDataInitializer.CreateUser(noSubUserName);

            var userData = new Domain.UserData(noSubUserName);

            //var userData = new Domain.UserData(noSubUserName);
            Assert.AreEqual(0, userData.SubverseSubscriptions.Count());
            Assert.AreEqual(false, userData.HasSubscriptions());
            Assert.AreEqual(false, userData.HasSubscriptions(DomainType.Subverse));

            //test subscription
            var subUserName = "******";

            VoatDataInitializer.CreateUser(subUserName);

            TestHelper.SetPrincipal(subUserName);
            var cmd = new SubscriptionCommand(Domain.Models.DomainType.Subverse, Domain.Models.SubscriptionAction.Subscribe, "unit");
            var x   = await cmd.Execute();

            userData = new Domain.UserData(subUserName);

            Assert.AreEqual(1, userData.SubverseSubscriptions.Count());
            Assert.AreEqual("unit", userData.SubverseSubscriptions.First());
            Assert.AreEqual(true, userData.HasSubscriptions());
            Assert.AreEqual(true, userData.HasSubscriptions(DomainType.Subverse));
            Assert.AreEqual(true, userData.IsUserSubverseSubscriber("unit"));
        }
        public IActionResult Param()
        {
            // Receive parameters from index.cshtml.
            string firstName = String.Format(Request.Form["firstName"].ToString());
            string lastName  = String.Format(Request.Form["lastName"].ToString());
            string mobileNum = String.Format(Request.Form["mobileNumber"].ToString());

            SubscriptionCommand command = new SubscriptionCommand();

            ViewBag.Message = command.Execute(firstName, lastName, mobileNum);

            return(View());
        }
Ejemplo n.º 3
0
        public async Task <IReadOnlyCollection <ITelegramResponse> > Handle(SubscriptionCommand request,
                                                                            CancellationToken cancellationToken)
        {
            var userState = await _userStateRepository.GetUserState(request.UserId, cancellationToken);

            if (userState.Subscribed != request.Subscribe)
            {
                userState = userState.ChangeSubscribe();
                await _userStateRepository.ChangeUserState(request.UserId, userState, cancellationToken);
            }

            var replyKeyboard = GetSettingReplyKeyboardMarkupFor(userState);
            var text          = $"You successfully {(userState.Subscribed ? "subscribed" : "unsubscribed")}";

            return(new[] { new KeyboardTelegramResponse(replyKeyboard, text) });
        }
Ejemplo n.º 4
0
 internal override void BuildAction(string action)
 {
     base.BuildAction(action);
     this.subscriptionCommand = new SubscriptionCommand(this.CommandArguments, this.SessionService.Object, this.FilterService.Object);
 }
 public AdapterFromSubscriptionCommandToCommand(SubscriptionCommand innerCommand)
 {
     _innerCommand = innerCommand;
 }