public long Insert_PostDetails(PostDetails post) { if (post != null) { object[] sqlParams = { new SqlParameter("@post_type", post.post_type), new SqlParameter("@post_email", post.post_email), new SqlParameter("@post_phoneNumber", post.post_phoneNumber), new SqlParameter("@post_address", post.post_address), new SqlParameter("@post_square", post.post_square), new SqlParameter("@post_price", post.post_price), new SqlParameter("@post_additonalInfo", post.post_additonalInfo) }; var res = context.Database.SqlQuery <long>("Sp_InsertPost @post_type,@post_email,@post_phoneNumber,@post_address,@post_square,@post_price,@post_additonalInfo", sqlParams).SingleOrDefault(); //System.Diagnostics.Debug.WriteLine("Inserted ID is: " + res.ToString()); return(res); } else { return(0); } }
// POST: api/UploadPost public void Post([FromBody] PostDetails post) { int count = post.post_images.Count(); System.Diagnostics.Debug.WriteLine(count.ToString()); // insert post PostModel model = new PostModel(); long id = model.Insert_PostDetails(post); if (id > 0) { List <string> Imglist = post.post_images; List <PostImageTableType> dataTable = new List <PostImageTableType>(); foreach (var item in Imglist) { var row = new PostImageTableType(); row.Post_Id = id; row.Url = item; dataTable.Add(row); } DataTable table = Code.Convert.ToDataTable(dataTable); model.Insert_PostImg(table); } //return count.ToString(); }
public static PostView Build(Post i_Post) { PostView postResult = new PostView(i_Post); postResult.Dock = DockStyle.Top; postResult.Padding = new Padding(0, 15, 0, 0); PostDetails details = new PostDetails(); PostBody body = new PostBody(); PostActions actions = new PostActions(); actions.Init(i_Post); body.Init(i_Post); details.Init(i_Post); details.Dock = DockStyle.Top; body.Dock = DockStyle.Top; actions.Dock = DockStyle.Top; postResult.Controls.Add(actions); postResult.Controls.Add(body); postResult.Controls.Add(details); details.UserClicked += postResult.OnUserClicked; return(postResult); }
public IActionResult PostDetails(int id) { var model = new PostDetails(); model.Post = _postRepository.Get(id); model.Category = _categoryRepository.Get(model.Post.CategoryID); return(View(model)); }
public async Task <IActionResult> View(int blogId, int postId, CancellationToken cancellationToken) { PostDetails details = await Mediator.Send(new GetPostQuery() { User = UserContext, PostId = postId, BlogId = blogId }, cancellationToken); return(View(details)); }
/*********************************************************************** * // DisplayEdit * // * /// <summary> * /// When a user replies to a post, the user control that controls the UI * /// is loaded and passed to this method. Elements of the form are then wired * /// up to handle events, such as button clicks * /// </summary> * /// <param name="control">Usercontrol used to control UI formatting</param> ***********************************************************************/ private void DisplayEdit(Control controlTemplate) { PostDetails post = null; Label label; TextBox textbox; Button button; if (Mode != CreateEditPostMode.EditPost) { return; } // Get the post to edit try { post = GetPostForEdit(); } catch (CannotEditPostException) { HttpContext.Current.Response.Redirect(Globals.UrlMessage + Convert.ToInt32(Messages.UnableToEditPost)); HttpContext.Current.Response.End(); } // Set the visibility ((Control)controlTemplate.FindControl("Edit")).Visible = true; ((Control)controlTemplate.FindControl("EditNotes")).Visible = true; // Set the title ((Label)controlTemplate.FindControl("PostTitle")).Text = Globals.HtmlDecode(EditMessageText); // Set the editor of the post ((Label)controlTemplate.FindControl("PostEditor")).Text = user.Username; // Set the Username label = (Label)controlTemplate.FindControl("PostAuthor"); label.Text = post.Username; // Set the Subject textbox = (TextBox)controlTemplate.FindControl("PostSubject"); textbox.Text = post.Subject; // Set the Body textbox = (TextBox)controlTemplate.FindControl("PostBody"); textbox.Text = post.Body; // Find the checkbox allowNoReplies = (CheckBox)controlTemplate.FindControl("AllowReplies"); // Wireup the preview button button = (Button)controlTemplate.FindControl("PreviewButton"); button.Click += new System.EventHandler(PreviewButton_Click); // Wire up the cancel button button = (Button)controlTemplate.FindControl("Cancel"); button.Click += new System.EventHandler(CancelButton_Click); // Wire up the post button button = (Button)controlTemplate.FindControl("PostButton"); button.Click += new System.EventHandler(PostButton_Click); }
private void NotifyConnectedClients(string geolocation, PostDetails post) { //var nearbyUsers = _repository.NearbyUsers(geolocation, 100); //foreach (var user in nearbyUsers) //{ // var connectionID = _repository.GetConnectionIdByUser(user.UserID); // Hub.Clients.Client(connectionID).AppendPost(post); //} }
public void Setup() { post = new PostDetails { Title = "title", Body = "post body", Id = 1, UserId = 1 }; users = new List <User> { new User { UserId = 1, Name = "Name", Email = "email", ImageUrl = "image" }, new User { UserId = 1, Name = "Name", Email = "l", ImageUrl = "image" } }; comments = new List <CommentExtended> { new Comment { Text = "comment", CommenterName = "name", PostId = 1, CommenterEmail = "email" } as CommentExtended, new Comment { Text = "comment", CommenterName = "name", PostId = 1, CommenterEmail = "l" } as CommentExtended, new Comment { Text = "comment", CommenterName = "name", PostId = 1, CommenterEmail = "l" } as CommentExtended, new Comment { Text = "comment", CommenterName = "name", PostId = 1, CommenterEmail = "email" } as CommentExtended }; postService = new Mock <IPostService>(); windowManager = new Mock <IWindowManager>(); userService = new Mock <IUserService>(); commentService = new Mock <ICommentService>(); loader = new Mock <ILoader>(); }
private PostFileStreamCreateModel PreparingPostFileStreamCreateModel(PostDetails postDetails, PostFileCategoryEnum postFileCategoryEnum) { return(new PostFileStreamCreateModel { PostFid = postDetails.PostFid, FileCategoryFid = (int)postFileCategoryEnum, FileCategoryResKey = "POST_FILE_CATEGORY_" + postFileCategoryEnum.ToString().ToUpper(), ActivatedDate = DateTime.Now, FileStreamFid = postDetails.FileStreamFid, FileTypeFid = (int)FileTypeEnum.Image, FileTypeResKey = "FILETYPE_" + FileTypeEnum.Image.ToString().ToUpper() }); }
/// <summary> /// Updates an post /// </summary> public override bool UpdatePost(PostDetails post) { using (SqlConnection cn = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("tbh_Forums_UpdatePost", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@PostID", SqlDbType.Int).Value = post.ID; cmd.Parameters.Add("@Title", SqlDbType.NVarChar).Value = post.Title; cmd.Parameters.Add("@Body", SqlDbType.NText).Value = post.Body; cn.Open(); int ret = ExecuteNonQuery(cmd); return(ret == 1); } }
private static void PutLikesAndFollowing(int numberOfPosts, PostDetails postdet) { if (postdet.PutLikesOnPostDetails(numberOfPosts, true)) { try { postdet.ClosePostDetailsPage(); } catch (Exception) { Console.WriteLine("Close details"); } } }
/// <summary> /// Returns a Post object filled with the data taken from the input PostDetails /// </summary> private static Post GetPostFromPostDetails(PostDetails record) { if (record == null) { return(null); } else { return(new Post(record.ID, record.AddedDate, record.AddedBy, record.AddedByIP, record.ForumID, record.ForumTitle, record.ParentPostID, record.Title, record.Body, record.Approved, record.Closed, record.ViewCount, record.ReplyCount, record.LastPostBy, record.LastPostDate)); } }
/// <summary> /// Updates an existing post /// </summary> public static bool UpdatePost(int id, string title, string body) { title = BizObject.ConvertNullToEmptyString(title); body = BizObject.ConvertNullToEmptyString(body); PostDetails record = new PostDetails(id, DateTime.Now, "", "", 0, "", 0, title, body, true, false, 0, 0, DateTime.Now, ""); bool ret = SiteProvider.Forums.UpdatePost(record); BizObject.PurgeCacheItems("forums_unapprovedposts"); BizObject.PurgeCacheItems("forums_threads"); BizObject.PurgeCacheItems("forums_threadcount"); BizObject.PurgeCacheItems("forums_thread_" + id.ToString()); BizObject.PurgeCacheItems("forums_post_" + id.ToString()); return(ret); }
// ********************************************************************* // GetPostDetails // /// <summary> /// Returns more detailed information about a Post than GetPost. /// </summary> /// <param name="PostID">The ID of the Post to obtain information about.</param> /// <param name="Username">The Username of the user viewing the post.</param> /// <param name="ConvertPostBodyFromRawToFormatted">A Boolean indicating whether or not /// to convert the post's raw database format into the HTML-ready formatted output.</param> /// <returns>A PostDetails object with detailed information about the post</returns> /// <remarks>GetPostDetails returns five bits of information that the GetPost method fails to: /// the PostID of the next/prev posts in the thread, the PostID of the first post in the /// next/prev threads, and whether or not the user viewing the post has email thread tracking /// turned on for the thread that the post belongs in. If you don't need this extra information, /// call the less resource intensive GetPost. <seealso cref="GetPost"/></remarks> /// // ***********************************************************************/ public static PostDetails GetPostDetails(int postID, String username, bool convertPostBodyFromRawToFormatted) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); if (convertPostBodyFromRawToFormatted) { PostDetails retPost = dp.GetPostDetails(postID, username); retPost.Body = Globals.FormatPostBody(retPost.Body); return(retPost); } else { return(dp.GetPostDetails(postID, username)); } }
public ApiActionResult CreateNewPost(PostCreateModel model) { try { model.UniqueId = UniqueIDHelper.GenerateRandomString(12); Posts obj = new Posts(); obj = _mapper.Map <Posts>(model); obj.LastModifiedDate = model.LastModifiedDate; obj.Deleted = false; var res = _dbCMSContext.Posts.Add(obj); _dbCMSContext.SaveChanges(); if (res.Entity.Id > 0) { model.postFileStream.ForEach(x => x.PostFid = res.Entity.Id); var objFileStream = model.postFileStream.Select(k => new PostFileStreams { FileCategoryFid = k.FileCategoryFid, FileCategoryResKey = k.FileCategoryResKey, PostFid = res.Entity.Id, FileStreamFid = k.FileStreamFid, FileTypeFid = k.FileTypeFid, FileTypeResKey = k.FileTypeResKey, ActivatedDate = k.ActivatedDate, LastModifiedDate = model.LastModifiedDate.Value, LastModifiedBy = k.LastModifiedBy, Deleted = false }); _dbCMSContext.PostFileStreams.AddRange(objFileStream); _dbCMSContext.SaveChanges(); PostDetails objDetail = new PostDetails(); objDetail = _mapper.Map <PostDetails>(model.postDetail); objDetail.LastModifiedDate = model.postDetail.LastModifiedDate; objDetail.Deleted = false; objDetail.PostFid = res.Entity.Id; var resDetail = _dbCMSContext.PostDetails.Add(objDetail); _dbCMSContext.SaveChanges(); } return(ApiActionResult.Success()); } catch (Exception ex) { return(ApiActionResult.Failed(ex.Message)); throw ex; } }
/*********************************************************************** * // DisplayReply * // * /// <summary> * /// When a user replies to a post, the user control that controls the UI * /// is loaded and passed to this method. Details such as the username, subject, * /// and message are extracted and displayed. * /// </summary> * /// <param name="control">Usercontrol used to control UI formatting</param> ***********************************************************************/ private void DisplayReply(Control control) { PostDetails post = null; HyperLink hyperlink; if (Mode == CreateEditPostMode.NewPost) { return; } // Set the visibility ((Control)control.FindControl("ReplyTo")).Visible = true; // Read in information about the post we are replying to try { post = Posts.GetPostDetails(PostID, Context.User.Identity.Name); } catch (Components.PostNotFoundException) { HttpContext.Current.Response.Redirect(Globals.UrlMessage + Convert.ToInt32(Messages.PostDoesNotExist)); HttpContext.Current.Response.End(); } // Don't allow replies to locked posts if (post.IsLocked) { HttpContext.Current.Response.Redirect(Globals.UrlShowPost + PostID); HttpContext.Current.Response.End(); } // Set the Username hyperlink = (HyperLink)control.FindControl("ReplyPostedBy"); hyperlink.Text = post.Username; hyperlink.NavigateUrl = Globals.UrlUserProfile + post.Username; // Set the date ((Label)control.FindControl("ReplyPostedByDate")).Text = " on " + post.PostDate.ToString(user.DateFormat + " " + Globals.TimeFormat); // Set the Subject hyperlink = (HyperLink)control.FindControl("ReplySubject"); hyperlink.Text = post.Subject; hyperlink.NavigateUrl = Globals.UrlShowPost + post.PostID; // Set the Body ((Label)control.FindControl("ReplyBody")).Text = Globals.FormatPostBody(post.Body); }
protected void Page_Load(object sender, EventArgs e) { if (Session["loggedInUsername"] == null) { Response.Redirect("Login.aspx"); } var authorusername = Session["loggedInUsername"].ToString().Trim(); myprofile.NavigateUrl = String.Format(myprofile.NavigateUrl, authorusername); if (!IsPostBack) { var postID = Request.QueryString["id"].ToString(); Forum fr = new Forum(postID); DataSet ds = frDAO.fetchCommentsforPost(fr); if (ds.Tables[0].Rows.Count > 0) { commentRepeater.Visible = true; commentRepeater.DataSource = ds; commentRepeater.DataBind(); } else { commentRepeater.Visible = false; } DataSet ds1 = frDAO.fetchPostInfo(fr); if (ds1.Tables[0].Rows.Count > 0) { PostDetails.Visible = true; PostDetails.DataSource = ds1; PostDetails.DataBind(); } else { PostDetails.Visible = false; } } }
private PostDetails GetPostForEdit() { PostDetails post = null; // Read in information about the post we are replying to try { post = Posts.GetPostDetails(PostID, Users.GetLoggedOnUser().Username); } catch (PostNotFoundException) { HttpContext.Current.Response.Redirect(Globals.UrlMessage + Convert.ToInt32(Messages.PostDoesNotExist)); HttpContext.Current.Response.End(); } // If the user attempting to edit is the same user that posted and the user is trusted, or the user is a moderator... if (((post.Username.ToLower() == Users.GetLoggedOnUser().Username.ToLower()) && (Users.GetLoggedOnUser().IsTrusted)) || (Users.GetLoggedOnUser().IsModerator)) { return(post); } throw new AspNetForums.Components.CannotEditPostException("User cannot edit post."); }
public IActionResult GetById(int id) { var post = _repo.GetById(id); if (post == null) { return(NotFound()); } var comments = _commentRepo.GetCommentsByPostId(id); var reactionCounts = _repo.GetReactionCounts(id); var postReactions = _repo.GetPostReactionsByPost(id); var postDetails = new PostDetails() { Post = post, ReactionCounts = reactionCounts, Comments = comments, PostReactions = postReactions }; return(Ok(postDetails)); }
/// <summary> /// Inserts a new post /// </summary> public override int InsertPost(PostDetails post) { using (SqlConnection cn = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("tbh_Forums_InsertPost", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value = post.AddedDate; cmd.Parameters.Add("@AddedBy", SqlDbType.NVarChar).Value = post.AddedBy; cmd.Parameters.Add("@AddedByIP", SqlDbType.NChar).Value = post.AddedByIP; cmd.Parameters.Add("@ForumID", SqlDbType.Int).Value = post.ForumID; cmd.Parameters.Add("@ParentPostID", SqlDbType.Int).Value = post.ParentPostID; cmd.Parameters.Add("@Title", SqlDbType.NVarChar).Value = post.Title; cmd.Parameters.Add("@Body", SqlDbType.NText).Value = post.Body; cmd.Parameters.Add("@Approved", SqlDbType.Bit).Value = post.Approved; cmd.Parameters.Add("@Closed", SqlDbType.Bit).Value = post.Closed; cmd.Parameters.Add("@PostID", SqlDbType.Int).Direction = ParameterDirection.Output; cn.Open(); int ret = ExecuteNonQuery(cmd); return((int)cmd.Parameters["@PostID"].Value); } }
public static async void Upload_Post(PostDetails post) { var client = new HttpClient(); //client.BaseAddress = new Uri("http://dangnguyenthehung.somee.com/XaganAPI/api/UploadPost/"); //client.BaseAddress = new Uri("http://localhost:64259/api/UploadPost/"); client.BaseAddress = new Uri("http://xaganapitest.gear.host/api/UploadPost/"); var jsonObject = JsonConvert.SerializeObject(post); System.Diagnostics.Debug.WriteLine(jsonObject); var content = new StringContent(jsonObject.ToString(), Encoding.UTF8, "application/json"); System.Diagnostics.Debug.WriteLine(content.ToString()); var result = await client.PostAsync(client.BaseAddress, content); System.Diagnostics.Debug.WriteLine("result: " + result.ToString()); }
/// <summary> /// Creates a new post /// </summary> public static int InsertPost(int forumID, int parentPostID, string title, string body, bool closed) { title = BizObject.ConvertNullToEmptyString(title); body = BizObject.ConvertNullToEmptyString(body); // if the target forum is moderated, the current user must be an // admin, editor or moderator to insert the post in approved status bool approved = true; Forum forum = Forum.GetForumByID(forumID); if (forum.Moderated) { if (!BizObject.CurrentUser.IsInRole("Administrators") && !BizObject.CurrentUser.IsInRole("Editors") && !BizObject.CurrentUser.IsInRole("Moderators")) { approved = false; } } PostDetails record = new PostDetails(0, DateTime.Now, BizObject.CurrentUserName, BizObject.CurrentUserIP, forumID, "", parentPostID, title, body, approved, closed, 0, 0, DateTime.Now, BizObject.CurrentUserName); int ret = SiteProvider.Forums.InsertPost(record); if (approved) { BizObject.PurgeCacheItems("forums_threads"); BizObject.PurgeCacheItems("forums_thread_" + parentPostID.ToString()); BizObject.PurgeCacheItems("forums_threadcount"); } else { BizObject.PurgeCacheItems("forums_unapprovedposts"); } return(ret); }
public ActionResult DetailsBySlug(string slug, string returnUrl) { if (string.IsNullOrWhiteSpace(slug)) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PostDetails postDetails = db.Posts .Where(p => p.Slug == slug) .Include(p => p.Comments.Select(t => t.Author)) .Select(p => new PostDetails { Id = p.Id, Title = p.Title, Slug = p.Slug, AuthorName = p.Author.DisplayName, Created = p.Created, Updated = p.Updated, MediaUrl = p.MediaUrl, Body = p.Body, RecentComments = p.Comments .OrderByDescending(c => c.Id) .Take(5) .ToList(), CommentCount = p.Comments.Count() }) .FirstOrDefault(); if (postDetails == null) { return(HttpNotFound()); } ViewBag.ReturnUrl = returnUrl; return(View("Details", postDetails)); }
public async Task <Post> LikePost(PostDetails post) { return(await RestApiHelper.ExecuteAsync <Post>(ApiEndpoints.GetPosts + post.ResourceIdentifier + "/like", HttpMethod.Post)); }
public Photo() { PostDetails = new PostDetails(); }
public async Task <ActionResult> History(string tid, string emailId) { if (string.IsNullOrEmpty(tid) || string.IsNullOrEmpty(emailId)) { return(HttpNotFound()); } emailId = emailId.ToLower(); var tenatInfo = await Common.CheckAndAddTenantDetails(tid); Role role = Common.GetUserRole(emailId, tenatInfo); var myTenantAnnouncements = await Common.GetMyAnnouncements(emailId, tenatInfo.Id); HistoryViewModel historyViewModel = new HistoryViewModel(); historyViewModel.Role = role; foreach (var announcement in myTenantAnnouncements.OrderByDescending(a => a.CreatedTime)) { //var campaign = announcement.Post as Campaign; PostDetails post = new PostDetails(); post.Id = announcement.Id; post.Title = announcement.Title; post.Date = announcement.CreatedTime; post.Status = announcement.Status; post.MessageSensitivity = announcement.Sensitivity; var recipientCount = 0; var groupsNames = new List <string>(); var channelNames = new List <string>(); // Get all group recipients foreach (var group in announcement.Recipients.Groups) { var groupname = await Cache.Groups.GetItemAsync(group.GroupId); if (groupname == null) { continue; } groupsNames.Add(groupname.Name); recipientCount += group.Users.Count; post.LikeCount += group.Users.Sum(u => u.LikeCount); post.AckCount += group.Users.Where(u => u.IsAcknoledged).Count(); } foreach (var team in announcement.Recipients.Channels) { var teamname = await Cache.Teams.GetItemAsync(team.TeamId); if (teamname == null) { continue; } if (!channelNames.Contains(teamname.Name)) { channelNames.Add(teamname.Name); post.RecipientChannelCount += teamname.Members.Count; } post.LikeCount += team.LikedUsers.Count; } if (recipientCount == 0 && announcement.Recipients != null && announcement.Recipients.Channels != null) { recipientCount = announcement.Recipients.Channels.Count; } var maxChar = 40; var recipientNames = string.Empty; var recipientChannelNames = string.Empty; for (int i = 0; i < groupsNames.Count; i++) { if (i != 0) { recipientNames += ", "; } recipientNames += groupsNames[i]; if (recipientNames.Length >= maxChar) { // Check the actual count recipientNames += " +" + (groupsNames.Count - i); break; } } for (int i = 0; i < channelNames.Count; i++) { if (i != 0) { recipientNames += ", "; } recipientChannelNames += channelNames[i]; if (recipientNames.Length >= maxChar) { // Check the actual count recipientChannelNames += " +" + (channelNames.Count - i); break; } } post.RecipientCount = $"{recipientCount}"; post.Recipients = $"{recipientNames}"; post.RecipientChannelNames = $"{recipientChannelNames}"; historyViewModel.Posts.Add(post); } return(View(historyViewModel)); }
private void CreateNewPost() { HasNewPost = true; CurrentPost = new PostDetails(); }
/// <summary> /// Inserts a new post /// </summary> public override int InsertPost(PostDetails post) { using (SqlConnection cn = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("tbh_Forums_InsertPost", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value = post.AddedDate; cmd.Parameters.Add("@AddedBy", SqlDbType.NVarChar).Value = post.AddedBy; cmd.Parameters.Add("@AddedByIP", SqlDbType.NChar).Value = post.AddedByIP; cmd.Parameters.Add("@ForumID", SqlDbType.Int).Value = post.ForumID; cmd.Parameters.Add("@ParentPostID", SqlDbType.Int).Value = post.ParentPostID; cmd.Parameters.Add("@Title", SqlDbType.NVarChar).Value = post.Title; cmd.Parameters.Add("@Body", SqlDbType.NText).Value = post.Body; cmd.Parameters.Add("@Approved", SqlDbType.Bit).Value = post.Approved; cmd.Parameters.Add("@Closed", SqlDbType.Bit).Value = post.Closed; cmd.Parameters.Add("@PostID", SqlDbType.Int).Direction = ParameterDirection.Output; cn.Open(); int ret = ExecuteNonQuery(cmd); return (int)cmd.Parameters["@PostID"].Value; } }
/// <summary> /// Updates an post /// </summary> public override bool UpdatePost(PostDetails post) { using (SqlConnection cn = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("tbh_Forums_UpdatePost", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@PostID", SqlDbType.Int).Value = post.ID; cmd.Parameters.Add("@Title", SqlDbType.NVarChar).Value = post.Title; cmd.Parameters.Add("@Body", SqlDbType.NText).Value = post.Body; cn.Open(); int ret = ExecuteNonQuery(cmd); return (ret == 1); } }