protected void btnSubmit_Click(object sender, EventArgs e) { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); DateTime currentDate = DateTime.Now; int PostID = ViewState["ID"].ToString().ToInt(0); var post = NotifyController.GetByID(PostID); if (post != null) { int CategoryID = hdfParentID.Value.ToInt(); var category = NotifyCategoryController.GetByID(CategoryID); string CategorySlug = category.Slug; string Title = txtTitle.Text.Trim(); string Slugs = Slug.ConvertToSlug(txtSlug.Text.Trim()); string Link = txtLink.Text.Trim(); string Content = pContent.Content.ToString(); string Summary = HttpUtility.HtmlDecode(pSummary.Content.ToString()); string Action = ddlAction.SelectedValue.ToString(); string ActionValue = ""; if (Action == "view_more") { ActionValue = Slugs; } else if (Action == "show_web") { ActionValue = Link; } bool AtHome = ddlAtHome.SelectedValue.ToBool(); //Phần thêm ảnh đại diện sản phẩm string path = "/uploads/images/posts/"; string Thumbnail = ListPostPublicThumbnail.Value; if (PostPublicThumbnailImage.UploadedFiles.Count > 0) { foreach (UploadedFile f in PostPublicThumbnailImage.UploadedFiles) { var o = path + "notify-" + PostID + '-' + Slug.ConvertToSlug(Path.GetFileName(f.FileName), isFile: true); try { f.SaveAs(Server.MapPath(o)); Thumbnail = o; } catch { } } } if (Thumbnail != ListPostPublicThumbnail.Value) { if (File.Exists(Server.MapPath(ListPostPublicThumbnail.Value))) { File.Delete(Server.MapPath(ListPostPublicThumbnail.Value)); } } // Update post var oldNotify = new NotifyNew() { ID = PostID, CategoryID = CategoryID, CategorySlug = CategorySlug, Title = Title, Thumbnail = Thumbnail, Summary = Summary, Content = Content, Action = Action, ActionValue = ActionValue, AtHome = AtHome, CreatedDate = post.CreatedDate, CreatedBy = acc.Username, ModifiedDate = currentDate, ModifiedBy = acc.Username }; var updatePost = NotifyController.Update(oldNotify); if (updatePost != null) { PJUtils.ShowMessageBoxSwAlertCallFunction("Cập nhật bài viết thành công", "s", true, "redirectTo(" + updatePost.ID.ToString() + ")", Page); } } }