public static string getAllPostImage(int id) { var post = PostController.GetByID(id); List <string> images = new List <string>(); if (post != null) { images.Add(post.Image); // lấy ảnh sản phẩm từ thư viện var imagePost = PostImageController.GetByPostID(post.ID); if (imagePost != null) { foreach (var img in imagePost) { images.Add(img.Image); } } } JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(images.Distinct().ToList())); }
public static string copyPostToApp(int id) { var post = PostController.GetByID(id); if (post != null) { var postCategory = PostCategoryController.GetByID(post.CategoryID.Value); PostCategory postPublicCategory = new PostCategory(); if (postCategory != null) { postPublicCategory = PostPublicCategoryController.GetByName(postCategory.Title); } var newPostPublic = new PostPublic() { CategoryID = postPublicCategory != null ? postPublicCategory.ID : 0, CategorySlug = postPublicCategory != null ? postPublicCategory.Slug : "", Title = post.Title, Thumbnail = post.Image, Summary = "", Content = post.Content, Action = "view_more", ActionValue = PostPublicController.checkSlug(post.Slug), AtHome = false, IsPolicy = false, CreatedDate = DateTime.Now, CreatedBy = post.CreatedBy, ModifiedDate = DateTime.Now, ModifiedBy = post.CreatedBy }; var newpost = PostPublicController.Insert(newPostPublic); if (newpost != null) { // Copy image gallery var postImage = PostImageController.GetToCopyByPostID(post.ID); if (postImage.Count > 0) { foreach (var img in postImage) { if (!string.IsNullOrEmpty(img.Image)) { string newImage = PostPublicImageController.Insert(newpost.ID, img.Image, newpost.CreatedBy, DateTime.Now); } } } return(newpost.ID.ToString()); } } return("false"); }
public static string deletePost(int id) { var post = PostController.GetByID(id); string result = ""; if (post != null) { // Delete thumbnail image if (!string.IsNullOrEmpty(post.Image)) { string fileImage = HttpContext.Current.Server.MapPath(post.Image); File.Delete(fileImage); } // Delete image gallery var postImage = PostImageController.GetByPostID(post.ID); if (postImage.Count > 0) { foreach (var img in postImage) { if (!string.IsNullOrEmpty(img.Image)) { string fileImage = HttpContext.Current.Server.MapPath(img.Image); File.Delete(fileImage); // Delete in database string deletePostImage = PostImageController.Delete(img.ID); } } } string deletePost = PostController.Delete(id); if (!string.IsNullOrEmpty(deletePost)) { result = "success"; } else { result = "failed"; } } else { result = "notfound"; } return(result); }
public void LoadData() { int id = Request.QueryString["id"].ToInt(0); if (id > 0) { var p = PostController.GetByID(id); if (p == null) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy bài viết " + id, "e", true, "/danh-sach-bai-viet", Page); } else { this.Title = String.Format("{0} - Sửa bài viết", p.Title.ToTitleCase()); ViewState["ID"] = id; ViewState["cateID"] = p.CategoryID; hdfParentID.Value = p.CategoryID.ToString(); ltrBack.Text = "<a href='/xem-bai-viet?id=" + p.ID + "' class='btn primary-btn fw-btn not-fullwidth'><i class='fa fa-arrow-left' aria-hidden='true'></i> Trở về</a>"; ltrBack2.Text = ltrBack.Text; txtTitle.Text = p.Title; txtSlug.Text = p.Slug; pContent.Content = p.Content; ddlCategory.SelectedValue = p.CategoryID.ToString(); ddlFeatured.SelectedValue = p.Featured.ToString(); if (p.Image != null) { ListPostThumbnail.Value = p.Image; PostThumbnail.ImageUrl = p.Image; } var image = PostImageController.GetByPostID(id); imageGallery.Text = "<ul class='image-gallery'>"; if (image != null) { foreach (var img in image) { imageGallery.Text += "<li><img src='" + img.Image + "'><a href='javascript:;' data-image-id='" + img.ID + "' onclick='deleteImageGallery($(this))' class='btn-delete'><i class='fa fa-times' aria-hidden='true'></i> Xóa hình</a></li>"; } } imageGallery.Text += "</ul>"; string PostInfo = "<p><strong>Ngày tạo</strong>: " + p.CreatedDate + "</p>"; PostInfo += "<p><strong>Người viết</strong>: " + p.CreatedBy + "</p>"; PostInfo += "<p><strong>Ngày cập nhật</strong>: " + p.ModifiedDate + "</p>"; PostInfo += "<p><strong>Người cập nhật</strong>: " + p.ModifiedBy + "</p>"; ltrPostInfo.Text = PostInfo; } } }
public void LoadData() { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); int id = Request.QueryString["id"].ToInt(0); if (id > 0) { var p = PostController.GetByID(id); if (p == null) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy bài viết " + id, "e", true, "/danh-sach-bai-viet", Page); } else { this.Title = String.Format("{0} - Bài viết", p.Title.ToTitleCase()); ltrEditTop.Text = ""; if (acc.RoleID == 0 || acc.Username == "nhom_zalo502") { ltrEditTop.Text += "<a href='/sua-bai-viet?id=" + p.ID + "' class='btn primary-btn fw-btn not-fullwidth'><i class='fa fa-pencil-square-o' aria-hidden='true'></i> Chỉnh sửa</a>"; } ltrEditTop.Text += "<a href='javascript:;' onclick='copyPostInfo(" + p.ID + ");' class='btn primary-btn not-fullwidth print-invoice-merged'><i class='fa fa-files-o'></i> Copy nội dung</a>"; ltrEditTop.Text += "<a href='javascript:;' onclick='getAllPostImage(" + p.ID + ");' class='btn primary-btn not-fullwidth print-invoice-merged'><i class='fa fa-cloud-download'></i> Tải hình</a>"; ltrEditTop.Text += "<a href='javascript:;' onclick='copyPostToApp(" + p.ID + ");' class='btn primary-btn not-fullwidth print-invoice-merged'><i class='fa fa-cloud-download'></i> Copy vào App</a>"; ltrEditBottom.Text = ltrEditTop.Text; ltrTitle.Text = p.Title; ltrContent.Text = p.Content; // thư viện ảnh imageGallery.Text = "<ul class='image-gallery'>"; if (!String.IsNullOrEmpty(p.Image)) { imageGallery.Text += "<li><img src='" + p.Image + "' /><a href='" + p.Image + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></li>"; } var image = PostImageController.GetByPostID(id); if (image != null) { foreach (var img in image) { if (img.Image != p.Image) { imageGallery.Text += "<li><img src='" + img.Image + "' /><a href='" + img.Image + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></li>"; } } } imageGallery.Text += "</ul>"; } } }
public void LoadData(int userRole) { int id = Request.QueryString["id"].ToInt(0); if (id > 0) { var p = PostController.GetByID(id); if (p == null) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy bài viết " + id, "e", true, "/danh-sach-bai-viet", Page); } else { ViewState["ID"] = id; ltrEdit.Text = ""; if (Convert.ToInt32(ViewState["role"]) == 0 || Convert.ToInt32(ViewState["role"]) == 1) { ltrEdit.Text += "<a href=\"/sua-bai-viet?id=" + p.ID + "\" class=\"btn primary-btn fw-btn not-fullwidth\"><i class=\"fa fa-pencil-square-o\" aria-hidden=\"true\"></i> Chỉnh sửa</a>"; ltrEdit.Text += "<a href=\"/tao-bai-viet\" class=\"btn primary-btn fw-btn not-fullwidth print-invoice-merged\"><i class=\"fa fa-file-text-o\" aria-hidden=\"true\"></i> Thêm mới</a>"; } ltrEdit.Text += "<a href=\"javascript:;\" onclick=\"copyPostInfo(" + p.ID + ")\" class=\"btn primary-btn not-fullwidth print-invoice-merged\"><i class=\"fa fa-files-o\"></i> Copy nội dung</a>"; ltrEdit.Text += "<a href=\"javascript:;\" onclick=\"getAllPostImage('" + p.ID + "');\" class=\"btn primary-btn not-fullwidth print-invoice-merged\"><i class=\"fa fa-cloud-download\"></i> Tải tất cả hình ảnh</a>"; ltrTitle.Text = p.Title; ltrContent.Text = p.Content; // thư viện ảnh var image = PostImageController.GetByPostID(id); imageGallery.Text = "<ul class=\"image-gallery\">"; imageGallery.Text += "<li><img src=\"" + p.Image + "\" /><a href='" + p.Image + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></li>"; if (image != null) { foreach (var img in image) { if (img.Image != p.Image) { imageGallery.Text += "<li><img src=\"" + img.Image + "\" /><a href='" + img.Image + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></li>"; } } } imageGallery.Text += "</ul>"; } } }
public void LoadData() { int id = Request.QueryString["id"].ToInt(0); if (id > 0) { var p = PostController.GetByID(id); if (p == null) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy sản phẩm " + id, "e", true, "/sp", Page); } else { ViewState["ID"] = id; ViewState["cateID"] = p.CategoryID; ltrProductName.Text = p.Title; ltrContent.Text = p.Content; if (p.Image != null) { PostThumbnail.Text = "<p><img src=\"" + p.Image + "\" /><a href='" + p.Image + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></p>"; } var image = PostImageController.GetByPostID(id); if (image != null) { foreach (var img in image) { if (img.Image != p.Image) { imageGallery.Text += "<p><img src=\"" + img.Image + "\" /><a href='" + img.Image + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></p>"; } } } ltrCopyProductInfoButton.Text = "<p><a href=\"javascript:;\" class=\"btn primary-btn copy-btn h45-btn\" onclick=\"copyPost(" + p.ID + ")\"><i class=\"fa fa-files-o\" aria-hidden=\"true\"></i> Copy</a></p>"; ltrDownloadProductImageButton.Text = "<a href =\"javascript:;\" class=\"btn primary-btn h45-btn\" onclick=\"getAllPostImage(" + p.ID + ");\"><i class=\"fa fa-cloud-download\" aria-hidden=\"true\"></i> Tải hình</a>"; } } }
public void LoadData() { int id = Request.QueryString["id"].ToInt(0); if (id > 0) { var p = PostController.GetByID(id); if (p == null) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy bài viết " + id, "e", true, "/danh-sach-bai-viet", Page); } else { ViewState["ID"] = id; ViewState["cateID"] = p.CategoryID; hdfParentID.Value = p.CategoryID.ToString(); ltrBack.Text = "<a href=\"/xem-bai-viet?id=" + p.ID + "\" class=\"btn primary-btn fw-btn not-fullwidth\">Trở về</a>"; txtPostTitle.Text = p.Title; pContent.Content = p.Content; ddlCategory.SelectedValue = p.CategoryID.ToString(); ddlFeatured.SelectedValue = p.Featured.ToString(); if (p.Image != null) { ListPostThumbnail.Value = p.Image; PostThumbnail.ImageUrl = p.Image; } var image = PostImageController.GetByPostID(id); imageGallery.Text = "<ul class=\"image-gallery\">"; if (image != null) { foreach (var img in image) { imageGallery.Text += "<li><img src='" + img.Image + "' /><a href='javascript:;' data-image-id='" + img.ID + "' onclick='deleteImageGallery($(this))' class='btn-delete'><i class=\"fa fa-times\" aria-hidden=\"true\"></i> Xóa hình</a></li>"; } } imageGallery.Text += "</ul>"; } } }
public static string deletePost(int id) { var post = PostController.GetByID(id); string result = ""; if (post != null) { // Delete image gallery var postImage = PostImageController.GetByPostID(post.ID); if (postImage.Count > 0) { foreach (var img in postImage) { if (!string.IsNullOrEmpty(img.Image)) { // Delete in database string deletePostImage = PostImageController.Delete(img.ID); } } } string deletePost = PostController.Delete(id); if (!string.IsNullOrEmpty(deletePost)) { result = "success"; } else { result = "failed"; } } else { result = "notfound"; } return(result); }
protected void btnSubmit_Click(object sender, EventArgs e) { string username = Request.Cookies["userLoginSystem"].Value; var acc = AccountController.GetByUsername(username); int cateID = ViewState["cateID"].ToString().ToInt(0); int PostID = ViewState["ID"].ToString().ToInt(0); if (cateID > 0) { string PostTitle = txtPostTitle.Text; string PostContent = pContent.Content; int CategoryID = hdfParentID.Value.ToInt(); //Phần thêm ảnh đại diện sản phẩm string path = "/uploads/images/"; string PostImage = ListPostThumbnail.Value; if (PostThumbnailImage.UploadedFiles.Count > 0) { foreach (UploadedFile f in PostThumbnailImage.UploadedFiles) { var o = path + PostID + '-' + convertToSlug(Path.GetFileName(f.FileName)); try { f.SaveAs(Server.MapPath(o)); PostImage = o; } catch { } } } if (PostImage != ListPostThumbnail.Value) { if (File.Exists(Server.MapPath(ListPostThumbnail.Value))) { File.Delete(Server.MapPath(ListPostThumbnail.Value)); } } // Delete Image Gallery string deleteImageGallery = hdfDeleteImageGallery.Value; if (deleteImageGallery != "") { string[] deletelist = deleteImageGallery.Split(','); for (int i = 0; i < deletelist.Length - 1; i++) { var img = PostImageController.GetByID(Convert.ToInt32(deletelist[i])); if (img != null) { var post = PostController.GetByID(PostID); // Delete image if (!string.IsNullOrEmpty(img.Image) && img.Image != post.Image) { string fileImage = Server.MapPath(img.Image); File.Delete(fileImage); } string delete = PostImageController.Delete(img.ID); } } } // Update product string kq = PostController.Update(PostID, PostTitle, PostContent, PostImage, ddlFeatured.SelectedValue.ToInt(), CategoryID, 1, username, DateTime.Now); // Upload image gallery if (UploadImages.HasFiles) { foreach (HttpPostedFile uploadedFile in UploadImages.PostedFiles) { var o = path + PostID + '-' + convertToSlug(Path.GetFileName(uploadedFile.FileName)); uploadedFile.SaveAs(Server.MapPath(o)); PostImageController.Insert(PostID, o, username, DateTime.Now); } } if (kq.ToInt(0) > 0) { PJUtils.ShowMessageBoxSwAlert("Cập nhật sản phẩm thành công", "s", true, Page); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); DateTime currentDate = DateTime.Now; int cateID = hdfParentID.Value.ToInt(); if (cateID > 0) { string Title = txtTitle.Text.Trim(); string PostSlug = Slug.ConvertToSlug(txtSlug.Text.Trim()); string Content = pContent.Content.ToString(); var newPost = new tbl_Post() { Title = Title, Content = Content, Image = "", Featured = ddlFeatured.SelectedValue.ToInt(), CategoryID = cateID, Status = 1, CreatedBy = acc.Username, CreatedDate = currentDate, ModifiedBy = acc.Username, ModifiedDate = currentDate, WebPublish = false, WebUpdate = currentDate, Slug = PostSlug }; var post = PostController.Insert(newPost); if (post != null) { //Phần thêm ảnh đại diện string path = "/uploads/images/posts/"; string Image = ""; if (ProductThumbnailImage.UploadedFiles.Count > 0) { foreach (UploadedFile f in ProductThumbnailImage.UploadedFiles) { var o = path + "post-" + post.ID + "-" + Slug.ConvertToSlug(Path.GetFileName(f.FileName), isFile: true); try { f.SaveAs(Server.MapPath(o)); Image = o; } catch { } } } string updateImage = PostController.UpdateImage(post.ID, Image); //Phần thêm thư viện ảnh string IMG = ""; if (hinhDaiDien.UploadedFiles.Count > 0) { foreach (UploadedFile f in hinhDaiDien.UploadedFiles) { var o = path + "post-" + post.ID + "-" + Slug.ConvertToSlug(Path.GetFileName(f.FileName), isFile: true); try { f.SaveAs(Server.MapPath(o)); IMG = o; PostImageController.Insert(post.ID, IMG, username, currentDate); } catch { } } } PJUtils.ShowMessageBoxSwAlertCallFunction("Tạo bài viết thành công", "s", true, "redirectTo(" + post.ID + ")", Page); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); DateTime currentDate = DateTime.Now; int cateID = hdfParentID.Value.ToInt(); if (cateID > 0) { int CategoryID = ddlCategory.Value.ToInt(); var category = PostPublicCategoryController.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(); bool IsPolicy = false; var newPostPublic = new PostPublic() { CategoryID = CategoryID, CategorySlug = CategorySlug, Title = Title, Thumbnail = "", Summary = Summary, Content = Content, Action = Action, ActionValue = ActionValue, AtHome = AtHome, IsPolicy = IsPolicy, CreatedDate = currentDate, CreatedBy = acc.Username, ModifiedDate = currentDate, ModifiedBy = acc.Username }; var post = PostPublicController.Insert(newPostPublic); if (post != null) { // Thêm ảnh đại diện string path = "/uploads/images/posts/"; string Image = ""; if (PostPublicThumbnailImage.UploadedFiles.Count > 0) { foreach (UploadedFile f in PostPublicThumbnailImage.UploadedFiles) { var o = path + "post-app-" + post.ID.ToString() + "-" + Slug.ConvertToSlug(Path.GetFileName(f.FileName), isFile: true); try { f.SaveAs(Server.MapPath(o)); Image = o; } catch { } } } string updateImage = PostPublicController.UpdateImage(post.ID, Image); // Thêm thư viện ảnh string IMG = ""; if (ImageGallery.UploadedFiles.Count > 0) { foreach (UploadedFile f in ImageGallery.UploadedFiles) { var o = path + "post-app-" + post.ID.ToString() + "-" + Slug.ConvertToSlug(Path.GetFileName(f.FileName), isFile: true); try { f.SaveAs(Server.MapPath(o)); IMG = o; PostPublicImageController.Insert(post.ID, IMG, username, currentDate); } catch { } } } // Copy bài viết vào hệ thống gốc if (ddlCopyToSystem.SelectedValue == "True" && post.Action == "view_more") { var categorySystem = PostCategoryController.GetByName(category.Name); var postSystem = new tbl_Post() { Title = post.Title, Content = post.Content, Image = Image, Featured = 1, CategoryID = categorySystem != null ? categorySystem.ID : 0, Status = 1, CreatedBy = post.CreatedBy, CreatedDate = post.CreatedDate, ModifiedBy = post.ModifiedBy, ModifiedDate = post.ModifiedDate, WebPublish = true, WebUpdate = post.CreatedDate, Slug = post.ActionValue }; PostController.Insert(postSystem); // Copy image if (postSystem != null) { var imagePostPublic = PostPublicImageController.GetByPostID(post.ID); if (imagePostPublic.Count > 0) { foreach (var item in imagePostPublic) { PostImageController.Insert(postSystem.ID, item.Image, postSystem.CreatedBy, DateTime.Now); } } } } // Tạo phiên bản cho wordpress if (!String.IsNullOrEmpty(hdfPostVariants.Value)) { JavaScriptSerializer serializer = new JavaScriptSerializer(); var variants = serializer.Deserialize <List <PostClone> >(hdfPostVariants.Value); if (variants != null) { foreach (var item in variants) { var newPostClone = new PostClone() { PostPublicID = post.ID, Web = item.Web, PostWebID = 0, CategoryID = post.CategoryID, CategoryName = category.Name, Title = !String.IsNullOrEmpty(item.Title) ? item.Title : post.Title, Summary = post.Summary, Content = post.Content, Thumbnail = Image, CreatedDate = post.CreatedDate, CreatedBy = acc.Username, ModifiedDate = post.ModifiedDate, ModifiedBy = acc.Username }; PostCloneController.Insert(newPostClone); } } } PJUtils.ShowMessageBoxSwAlertCallFunction("Tạo bài viết thành công", "s", true, "redirectTo(" + post.ID.ToString() + ")", Page); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); int cateID = ViewState["cateID"].ToString().ToInt(0); int PostID = ViewState["ID"].ToString().ToInt(0); if (cateID > 0) { string Title = txtTitle.Text.Trim(); string PostSlug = Slug.ConvertToSlug(txtSlug.Text.Trim()); string Content = pContent.Content.ToString(); int CategoryID = hdfParentID.Value.ToInt(); //Phần thêm ảnh đại diện sản phẩm string path = "/uploads/images/posts/"; string PostImage = ListPostThumbnail.Value; if (PostThumbnailImage.UploadedFiles.Count > 0) { foreach (UploadedFile f in PostThumbnailImage.UploadedFiles) { var o = path + "post-" + PostID + '-' + Slug.ConvertToSlug(Path.GetFileName(f.FileName), isFile: true); try { f.SaveAs(Server.MapPath(o)); PostImage = o; } catch { } } } // Delete Image Gallery string deleteImageGallery = hdfDeleteImageGallery.Value; if (deleteImageGallery != "") { string[] deletelist = deleteImageGallery.Split(','); for (int i = 0; i < deletelist.Length - 1; i++) { var img = PostImageController.GetByID(Convert.ToInt32(deletelist[i])); if (img != null) { string delete = PostImageController.Delete(img.ID); } } } // Update post string kq = PostController.Update(PostID, Title, Content, PostImage, ddlFeatured.SelectedValue.ToInt(), CategoryID, 1, PostSlug, username, DateTime.Now); // Upload image gallery if (UploadImages.HasFiles) { foreach (HttpPostedFile uploadedFile in UploadImages.PostedFiles) { var o = path + "post-" + PostID + '-' + Slug.ConvertToSlug(Path.GetFileName(uploadedFile.FileName), isFile: true); uploadedFile.SaveAs(Server.MapPath(o)); PostImageController.Insert(PostID, o, username, DateTime.Now); } } if (kq.ToInt(0) > 0) { PJUtils.ShowMessageBoxSwAlertCallFunction("Cập nhật bài viết thành công", "s", true, "redirectTo(" + kq + ")", Page); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { string username = Request.Cookies["userLoginSystem"].Value; var acc = AccountController.GetByUsername(username); DateTime currentDate = DateTime.Now; if (acc != null) { if (acc.RoleID == 0 || acc.RoleID == 1) { int cateID = hdfParentID.Value.ToInt(); if (cateID > 0) { string Title = txtTitle.Text.ToString(); string Content = pContent.Content.ToString(); string kq = PostController.Insert(Title, Content, "", ddlFeatured.SelectedValue.ToInt(), cateID, 1, acc.Username, currentDate); //Phần thêm ảnh đại diện string path = "/uploads/images/"; string Image = ""; if (ProductThumbnailImage.UploadedFiles.Count > 0) { foreach (UploadedFile f in ProductThumbnailImage.UploadedFiles) { var o = path + kq + '-' + convertToSlug(Path.GetFileName(f.FileName)); try { f.SaveAs(Server.MapPath(o)); Image = o; } catch { } } } string updateImage = PostController.UpdateImage(kq.ToInt(), Image); //Phần thêm thư viện ảnh string IMG = ""; if (hinhDaiDien.UploadedFiles.Count > 0) { foreach (UploadedFile f in hinhDaiDien.UploadedFiles) { var o = path + kq + '-' + convertToSlug(Path.GetFileName(f.FileName)); try { f.SaveAs(Server.MapPath(o)); IMG = o; PostImageController.Insert(kq.ToInt(), IMG, username, currentDate); } catch { } } } if (kq.ToInt(0) > 0) { PJUtils.ShowMessageBoxSwAlertCallFunction("Tạo sản phẩm thành công", "s", true, "redirectTo(" + kq + ")", Page); } } } } }