Ejemplo n.º 1
0
        public void LoadCategory()
        {
            var category = NotifyCategoryController.GetAll();

            ddlCategory.Items.Clear();
            ddlCategory.Items.Insert(0, new ListItem("Chọn danh mục", "0"));
            if (category.Count > 0)
            {
                addItemCategory(0, "");
                ddlCategory.DataBind();
            }
        }
Ejemplo n.º 2
0
        public void addItemCategory(int id, string h = "")
        {
            var categories = NotifyCategoryController.GetByParentID("", id);

            if (categories.Count > 0)
            {
                foreach (var c in categories)
                {
                    ListItem listitem = new ListItem(h + c.Name, c.ID.ToString());
                    ddlCategory.Items.Add(listitem);

                    addItemCategory(c.ID, h + "---");
                }
            }
        }
Ejemplo n.º 3
0
        public static string getParent(int parent)
        {
            List <GetOutCategory> gc = new List <GetOutCategory>();

            if (parent != 0)
            {
                var parentlist = NotifyCategoryController.API_GetByParentID(parent);
                if (parentlist != null)
                {
                    for (int i = 0; i < parentlist.Count; i++)
                    {
                        GetOutCategory go = new GetOutCategory();
                        go.ID           = parentlist[i].ID;
                        go.CategoryName = parentlist[i].Name;
                        gc.Add(go);
                    }
                }
            }
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            return(serializer.Serialize(gc));
        }
Ejemplo n.º 4
0
        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     = 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();

                var newNotify = new NotifyNew()
                {
                    CategoryID   = CategoryID,
                    CategorySlug = CategorySlug,
                    Title        = Title,
                    Thumbnail    = "",
                    Summary      = Summary,
                    Content      = Content,
                    Action       = Action,
                    ActionValue  = ActionValue,
                    AtHome       = AtHome,
                    CreatedDate  = currentDate,
                    CreatedBy    = acc.Username,
                    ModifiedDate = currentDate,
                    ModifiedBy   = acc.Username,
                    AppUpdate    = currentDate
                };

                var post = NotifyController.Insert(newNotify);

                //Phần 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 + "notify-" + post.ID.ToString() + "-" + Slug.ConvertToSlug(Path.GetFileName(f.FileName), isFile: true);
                        try
                        {
                            f.SaveAs(Server.MapPath(o));
                            Image = o;
                        }
                        catch { }
                    }
                }
                string updateImage = NotifyController.UpdateImage(post.ID, Image);

                if (post != null)
                {
                    PJUtils.ShowMessageBoxSwAlertCallFunction("Tạo thông báo thành công", "s", true, "redirectTo(" + post.ID.ToString() + ")", Page);
                }
            }
        }