コード例 #1
0
 public void Initialize()
 {
     dto = new DeleteSubscription
     {
         Id = DataFormats.CreateEntityIdentifier()
     };
     validator = new DeleteSubscriptionValidator();
 }
コード例 #2
0
 void Propagate(DeleteSubscription request)
 {
     if (!string.IsNullOrEmpty(request.Cooperator))
     {
         var client        = new RestClient(request.Cooperator);
         var requestToSend = new RestRequest($"topics/{request.TopicName}/subscriptions/{request.SubscriberId}", Method.DELETE);
         client.Execute(requestToSend);
     }
 }
コード例 #3
0
        public void ShouldDeleteSubscription()
        {
            var mockSubRepo = new Mock <ISubscriptionRepository>();

            mockSubRepo.Setup(m => m.Delete(0)).Returns(true);

            var delete = new DeleteSubscription(mockSubRepo.Object, 0).Execute();

            Assert.IsTrue(delete);
        }
コード例 #4
0
        public IActionResult Delete(long id)
        {
            var result = new DeleteSubscription(Repository, id).Execute();

            if (!result)
            {
                return(NotFound());
            }
            return(Ok());
        }
コード例 #5
0
ファイル: MainWindow.xaml.cs プロジェクト: andr9528/Unipay
        private void DeleteSubscription_Click(object sender, RoutedEventArgs e)
        {
            DeleteSubscription delsub = new DeleteSubscription();

            delsub.Title = "Delete";

            delsub.ShowDialog();

            data.ExportBackup();

            UpdateView();
        }
コード例 #6
0
        public DeleteSubscriptionResponse Delete(DeleteSubscription request)
        {
            var subscription = Store.Get(request.Id);

            if (subscription == null)
            {
                throw HttpError.NotFound(null);
            }

            Store.Delete(subscription.Id);

            logger.InfoFormat(@"[ServiceStack.Webhooks.ServiceInterface.SubscriptionService] Deleted subscription {0} by user {1}", subscription.Id, Caller.UserId);

            return(new DeleteSubscriptionResponse());
        }
コード例 #7
0
        public void Delete(DeleteSubscription request)
        {
            var topicLock = Locks.TakeTopicLock(request.TopicName);

            lock (topicLock)
            {
                if (Locks.TopicsRecoveryLocks.ContainsKey(request.TopicName))
                {
                    throw new Exception($"Topic {request.TopicName} is inconsistent");
                }

                using (var connection = Connections.ConnectToInitializedTopic(request.TopicName))
                {
                    connection.DeleteById <Subscriber>(request.SubscriberId);
                }

                Propagators.ScheduleTopicOperation(request.TopicName, () => Propagate(request));
            }
        }
コード例 #8
0
 protected override Expression <Func <IReactiveProxy, Task> > VisitDeleteSubscription(DeleteSubscription operation)
 {
     return(Reduce(s_this.Let(@this =>
                              Expression.Lambda <Func <IReactiveProxy, Task> >(
                                  Expression.Invoke(
                                      s_disposeSubscriptionExpr,
                                      Expression.Constant(operation.TargetObjectUri),
                                      @this),
                                  @this))));
 }
コード例 #9
0
        public DTO <DeleteSubscriptionDTO> DeleteSubscription(Models.Input <DeleteSubscription> obj)
        {
            Models.DTO <DeleteSubscriptionDTO> dto = new Models.DTO <DeleteSubscriptionDTO>();
            DeleteSubscriptionDTO resp             = new DeleteSubscriptionDTO();

            dto.objname = "DeleteSubscription";
            try
            {
                /* Check required parameters */
                if (string.IsNullOrEmpty(obj.input.username) || string.IsNullOrEmpty(obj.input.password) || string.IsNullOrEmpty(obj.input.authkey) || string.IsNullOrEmpty(obj.input.hash) || string.IsNullOrEmpty(obj.input.msisdn))
                {
                    dto.status = new Models.Status(800);
                    return(dto);
                }
                Authentication ar   = new Authentication();
                string         hash = ar.UserAuth(obj.input.msisdn, obj.input.service);

                string     uri    = ConfigurationManager.AppSettings["oneglobalDOB"].ToString();
                string     url    = uri + "/DeleteSubscription";
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(url);
                if (url != null)
                {
                    try
                    {
                        JavaScriptSerializer jdes = new JavaScriptSerializer();
                        var reqObj = new DeleteSubscription();

                        reqObj.username = obj.input.username;
                        reqObj.password = obj.input.password;
                        reqObj.authkey  = obj.input.authkey;
                        reqObj.service  = obj.input.service;
                        reqObj.hash     = hash;
                        reqObj.msisdn   = obj.input.msisdn;
                        reqObj.appuser  = "******";

                        Input <DeleteSubscription> inp = new Input <DeleteSubscription>();
                        inp.input = reqObj;

                        client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                        client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");

                        HttpResponseMessage response = client.PostAsJsonAsync(url, inp).Result;

                        if (response.IsSuccessStatusCode)
                        {
                            if (response != null)
                            {
                                Task <String> ss     = response.Content.ReadAsStringAsync();
                                var           result = JsonConvert.DeserializeObject <Models.DTO <DeleteSubscriptionDTO> >(ss.Result);

                                if (result != null)
                                {
                                    dto.response = result.response;
                                    dto.status   = result.status;
                                    return(dto);
                                }
                            }
                        }
                    }
                    catch (HttpRequestException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                dto.status = new Models.Status(1);
            }
            return(dto);
        }