internal static async Task <bool> ShowNextForPagingWithTestimonials(string site, int pageIndex, int pageSize) { await using var cmd = new SqlCommand("[dbo].[GetWorksPagingWithTestimonials]", new Base().SqlConnection) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.Add("@Site", SqlDbType.NVarChar, 25).Value = site; cmd.Parameters.Add("@PageIndex", SqlDbType.Int).Value = pageIndex; cmd.Parameters.Add("@PageSize", SqlDbType.Int).Value = pageSize; SqlParameter showNext = cmd.Parameters.Add("@ShowNext", SqlDbType.Bit); showNext.Direction = ParameterDirection.Output; await cmd.Connection.OpenAsync(); await cmd.ExecuteNonQueryAsync(); await cmd.Connection.CloseAsync(); bool output = Implicit.Bool(showNext.Value); return(output); }
public async Task <IActionResult> OnPostSaveComment(string author, string email, string text, string exists) { if ((string.IsNullOrWhiteSpace(author)) || (string.IsNullOrWhiteSpace(email)) || (string.IsNullOrWhiteSpace(text)) || (string.IsNullOrWhiteSpace(exists))) { return(ViewComponent("Comments")); } var commentsComponentModel = Session.Json.GetObject <CommentsComponentModel>(HttpContext.Session, Session.Key.CommentsComponentModel); PostDataModel?post = await BlogService.GetPostById(commentsComponentModel.PostId).ConfigureAwait(true); if (post == null) { throw new NullReferenceException("Post could not be derived from session."); } var commentModel = new CommentModel { Author = author, Email = email, IsAdmin = User.Identity.IsAuthenticated, Text = text }; bool elementExists = Implicit.Bool(exists); // the website form key should have been removed by javascript unless the comment was posted by a spam robot // ReSharper disable once InvertIf if (!elementExists) { post.Comments.Add(commentModel); await BlogService.SavePost(post).ConfigureAwait(false); } return(ViewComponent("Comments")); }