Пример #1
0
 public ClientModel Create([FromBody] CommentClient comment)
 {
     SaveComment(comment);
     comment.ServerActionKey = "Save";
     comment.ServerStatus    = true;
     return(comment);
 }
Пример #2
0
 public ClientModel Update(string key, [FromBody] CommentClient comment)
 {
     SaveComment(comment);
     comment.ServerActionKey = "Save";
     comment.ServerStatus    = true;
     return(comment);
 }
Пример #3
0
        public async Task GetByPodcastIdAsync_PodcastIdZero_Throw()
        {
            var apiConnection = Substitute.For <IApiConnection>();
            var client        = new CommentClient(apiConnection);

            await Assert.ThrowsExceptionAsync <ArgumentOutOfRangeException>(async() => await client.GetByPodcastIdAsync(0));

            await apiConnection.DidNotReceive().ExecuteGetCollectionAsync <Comment>(Arg.Any <string>());
        }
Пример #4
0
        public async Task GetByIdAsync_CommentIdEmpty_Throw()
        {
            var apiConnection = Substitute.For <IApiConnection>();
            var client        = new CommentClient(apiConnection);

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await client.GetByIdAsync(string.Empty));

            await apiConnection.DidNotReceive().ExecuteGetAsync <Comment>(Arg.Any <string>());
        }
Пример #5
0
 public ClientModel CheckUploadPermissionForNewComment([FromBody] CommentClient comment)
 {
     comment.ClearNotifications();
     comment.CanUploadDocument = _commentDriver.HasPermission(EntityPermission.UploadDocument, threadId: comment.ThreadId) == OperationStatus.Granted;
     comment.CanUploadImage    = _commentDriver.HasPermission(EntityPermission.UploadImage, threadId: comment.ThreadId) == OperationStatus.Granted;
     comment.ServerActionKey   = "CheckUploadPermission";
     comment.ServerStatus      = true;
     return(comment);
 }
Пример #6
0
        public async Task GetByIdAsync()
        {
            var apiConnection = Substitute.For <IApiConnection>();
            var client        = new CommentClient(apiConnection);

            await client.GetByIdAsync("123");

            await apiConnection.Received().ExecuteGetAsync <Comment>("comments/123");
        }
Пример #7
0
        public async Task GetByPodcastIdAsync()
        {
            var apiConnection = Substitute.For <IApiConnection>();
            var client        = new CommentClient(apiConnection);

            await client.GetByPodcastIdAsync(1);

            await apiConnection.Received().ExecuteGetCollectionAsync <Comment>("comments?p_id=1");
        }
Пример #8
0
 //- @GetCommentList -//
 public static List <Comment> GetCommentList(String blogEntryGuid, Boolean showEveryComment)
 {
     using (CommentClient commentClient = new CommentClient(MinimaConfiguration.ActiveCommentServiceEndpoint))
     {
         commentClient.ClientCredentials.UserName.UserName = MinimaConfiguration.DefaultServiceUserName;
         commentClient.ClientCredentials.UserName.Password = MinimaConfiguration.DefaultServicePassword;
         //+
         return(commentClient.GetCommentList(blogEntryGuid, showEveryComment));
     }
 }
Пример #9
0
 //- @PostNewComment -//
 public static String PostNewComment(String blogEntryGuid, String text, String author, String email, String website, DateTime dateTime, String emailBodyTemplate, String emailSubject)
 {
     using (CommentClient commentClient = new CommentClient(BlogSection.GetConfigSection().Service.Endpoint.Comment))
     {
         commentClient.ClientCredentials.UserName.UserName = BlogSection.GetConfigSection().Service.Authentication.DefaultUserName;
         commentClient.ClientCredentials.UserName.Password = BlogSection.GetConfigSection().Service.Authentication.DefaultPassword;
         //+
         return(commentClient.PostNewComment(blogEntryGuid, text, author, email, website, dateTime, emailBodyTemplate, emailSubject));
     }
 }
Пример #10
0
 //- @GetCommentList -//
 public static List <Comment> GetCommentList(String blogEntryGuid, Boolean showEveryComment)
 {
     using (CommentClient commentClient = new CommentClient(BlogSection.GetConfigSection().Service.Endpoint.Comment))
     {
         commentClient.ClientCredentials.UserName.UserName = BlogSection.GetConfigSection().Service.Authentication.DefaultUserName;
         commentClient.ClientCredentials.UserName.Password = BlogSection.GetConfigSection().Service.Authentication.DefaultPassword;
         //+
         return(commentClient.GetCommentList(blogEntryGuid, showEveryComment));
     }
 }
Пример #11
0
 //- @AuthorizeComment -//
 public static void AuthorizeComment(String commentGuid)
 {
     using (CommentClient commentClient = new CommentClient(BlogSection.GetConfigSection().Service.Endpoint.Comment))
     {
         commentClient.ClientCredentials.UserName.UserName = BlogSection.GetConfigSection().Service.Authentication.DefaultUserName;
         commentClient.ClientCredentials.UserName.Password = BlogSection.GetConfigSection().Service.Authentication.DefaultPassword;
         //+
         commentClient.AuthorizeComment(commentGuid);
     }
 }
Пример #12
0
 //- @PostNewComment -//
 public static String PostNewComment(String blogEntryGuid, String text, String author, String email, String website, DateTime dateTime, String emailBodyTemplate, String emailSubject)
 {
     using (CommentClient commentClient = new CommentClient(MinimaConfiguration.ActiveCommentServiceEndpoint))
     {
         commentClient.ClientCredentials.UserName.UserName = MinimaConfiguration.DefaultServiceUserName;
         commentClient.ClientCredentials.UserName.Password = MinimaConfiguration.DefaultServicePassword;
         //+
         return(commentClient.PostNewComment(blogEntryGuid, text, author, email, website, dateTime, emailBodyTemplate, emailSubject));
     }
 }
Пример #13
0
 //- @AuthorizeComment -//
 public static void AuthorizeComment(String commentGuid)
 {
     using (CommentClient commentClient = new CommentClient(MinimaConfiguration.ActiveCommentServiceEndpoint))
     {
         commentClient.ClientCredentials.UserName.UserName = MinimaConfiguration.DefaultServiceUserName;
         commentClient.ClientCredentials.UserName.Password = MinimaConfiguration.DefaultServicePassword;
         //+
         commentClient.AuthorizeComment(commentGuid);
     }
 }
Пример #14
0
        public IActionResult AnswerComment(CommentClient cc)
        {
            if (!HttpContext.User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }


            CommentShop.Create(cc.ID_comment_client, cc.CommentShop.Comment_shop);

            return(Redirect("Comment"));
        }
Пример #15
0
        public IActionResult AnswerComment(string ID_comment_client)
        {
            if (!HttpContext.User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }


            var CC = CommentClient.GetComment(ID_comment_client);

            return(View(CC));
        }
Пример #16
0
 private void SaveComment(CommentClient comment)
 {
     var status = _commentDriver.Save(comment);
     if (status == OperationStatus.Success)
     {
         comment.AddSuccessNotification(MessageManager.GetMessage(status));
     }
     else
     {
         comment.AddErrorNotification(MessageManager.GetMessage(status));
     }
 }
Пример #17
0
        /////////////////////////
        // Комментарии
        /////////////////////////
        #region
        //[Authorize]
        public IActionResult Comment()
        {
            if (!HttpContext.User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }


            List <CommentClient> cm = CommentClient.GetComments(User.Identity.Name);

            return(View(cm));
        }
Пример #18
0
        private void SaveComment(CommentClient comment)
        {
            var status = _commentDriver.Save(comment);

            if (status == OperationStatus.Success)
            {
                comment.AddSuccessNotification(MessageManager.GetMessage(status));
            }
            else
            {
                comment.AddErrorNotification(MessageManager.GetMessage(status));
            }
        }
Пример #19
0
        //[Authorize]
        public IActionResult DeleteComment(string ID_comment_client)
        {
            if (!HttpContext.User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }


            CommentClient.DeleteVisible(ID_comment_client);

            var referrer = Request.Headers["Referer"];

            return(Redirect(referrer));
        }
Пример #20
0
        /// <summary>
        /// API client
        /// </summary>
        /// <remarks>
        /// See the <a href="https://docs.dev.to/api/#section/Authentication/api_key">Authentication</a> for more information
        /// </remarks>
        /// <param name="apiUrl">API connection url</param>
        /// <param name="token">API key</param>
        public DevToClient(string apiUrl, string token)
        {
            var restClient = new RestClient(apiUrl);

            restClient.AddDefaultHeader("api-key", token);
            restClient.AddDefaultHeader("User-Agent", "DevToAPI-client-dotnet");
            var apiConnection = new ApiConnection(restClient);

            AdminConfigurations = new AdminConfigurationClient(apiConnection);
            Articles            = new ArticleClient(apiConnection);
            Comments            = new CommentClient(apiConnection);
            Followers           = new FollowerClient(apiConnection);
            Follows             = new FollowClient(apiConnection);
            Listings            = new ListingClient(apiConnection);
            Organizations       = new OrganizationClient(apiConnection);
            PodcastEpisodes     = new PodcastEpisodeClient(apiConnection);
            ReadingLists        = new ReadingListClient(apiConnection);
            Tags          = new TagClient(apiConnection);
            Users         = new UserClient(apiConnection);
            Videos        = new VideoClient(apiConnection);
            Webhooks      = new WebhookClient(apiConnection);
            ProfileImages = new ProfileImageClient(apiConnection);
        }
Пример #21
0
 /// <inheritdoc />
 internal IllustClient(PixivClient pixivClient) : base(pixivClient)
 {
     Bookmark = new BookmarkClient(pixivClient);
     Comment  = new CommentClient(pixivClient);
 }
        public void GetCommentShop(string connectionString, string id_shop)
        {
            Comments = new List <CommentClient>();
            SqlConnection connection = new SqlConnection(connectionString);


            string sqlExpression = @"SELECT 
                    COMCL.ID_comment_client,
                    COMCL.ID_shop,
                    COMCL.Email,
                    COMCL.Name,
                    COMCL.Comment,
                    COMCL.Count_star,
                    COMCL.Date_add,
                    CS.ID_comment_shop,
                    CS.Comment AS comment_shop,
                    CS.Date_add AS Date_add_shop

                        FROM SPAVREMONT.Comment_Client COMCL
                    LEFT JOIN SPAVREMONT.Comment_shop CS ON CS.id_comment_shop=COMCL.id_comment_shop
                    WHERE COMCL.id_shop='" + id_shop + @"'
                        AND COMCL.DELETED=0
                        AND COMCL.VISIBLE=1
                    ORDER BY COMCL.Date_add DESC
                    ";

            connection.Open();
            SqlCommand command = new SqlCommand();

            command.CommandText = sqlExpression;
            command.Connection  = connection;
            SqlDataReader reader = command.ExecuteReader();

            if (reader.HasRows) // если есть данные
            {
                //int genreIDIndex = reader.GetOrdinal("GenreID");
                //...
                //while...
                //GenreID = reader.IsDBNull(genreIDIndex) ? null : reader.GetInt32(genreIDIndex)

                int ccID_comment_clientIndex = reader.GetOrdinal("ID_comment_client");
                int ccID_shopIndex           = reader.GetOrdinal("ID_shop");
                int ccEmailIndex             = reader.GetOrdinal("Email");
                int ccNameIndex            = reader.GetOrdinal("Name");
                int ccCommentIndex         = reader.GetOrdinal("Comment");
                int ccCount_starIndex      = reader.GetOrdinal("Count_star");
                int ccDate_addIndex        = reader.GetOrdinal("Date_add");
                int csID_comment_shopIndex = reader.GetOrdinal("ID_comment_shop");
                int csCommentShopIndex     = reader.GetOrdinal("comment_shop");
                int csDate_add_shopIndex   = reader.GetOrdinal("Date_add_shop");



                while (reader.Read()) // построчно считываем данные
                {
                    CommentShop comment_shop = new CommentShop
                    {
                        ID_comment_shop = reader.IsDBNull(csID_comment_shopIndex) ? null : reader.GetString(csID_comment_shopIndex),
                        Comment         = reader.IsDBNull(csCommentShopIndex) ? null : reader.GetString(csCommentShopIndex)
                    };

                    if (!reader.IsDBNull(csDate_add_shopIndex))// если дата существует в запросе
                    {
                        comment_shop.Date_add = reader.GetDateTime(csDate_add_shopIndex);
                    }

                    CommentClient itemCommentClient = new CommentClient
                    {
                        Comment      = reader.IsDBNull(ccCommentIndex) ? null : reader.GetString(ccCommentIndex),
                        Comment_shop = comment_shop,
                        Count_star   = reader.IsDBNull(ccCount_starIndex) ? 0 : reader.GetByte(ccCount_starIndex),
                        Date_add     = reader.GetDateTime(ccDate_addIndex),
                        //Email= reader.IsDBNull(ccCommentIndex) ? null : reader.GetString(ccCommentIndex),// аноним для всех, виден только для магазина
                        ID_comment_client = reader.IsDBNull(ccID_comment_clientIndex) ? null : reader.GetString(ccID_comment_clientIndex),
                        ID_shop           = reader.IsDBNull(ccID_shopIndex) ? null : reader.GetString(ccID_shopIndex),
                        Name = reader.IsDBNull(ccNameIndex) ? null : reader.GetString(ccNameIndex)
                    };

                    Comments.Add(itemCommentClient);
                }



                //return shops;
            }
        }
Пример #23
0
 public VideoCommentService(CommentClient commentClient)
 {
     CommentClient = commentClient;
 }
Пример #24
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 public NicoLiveCommandData()
 {
     NicoClient    = new NicoClient();
     CommentClient = new CommentClient();
 }