Пример #1
0
 public ActionResult Edit(Category obj)
 {
     if (string.IsNullOrEmpty(obj.Name) || obj.MenuId == Guid.Empty)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
     else
     {
         Category model = CateBLL.GetById(obj.Id);
         if (model == null)
         {
             return(Json(false, JsonRequestBehavior.AllowGet));
         }
         else
         {
             model.Name      = obj.Name;
             model.ShowOrder = obj.ShowOrder;
             model.ParentId  = obj.ParentId;
             model.MenuId    = obj.MenuId;
             UrlRecord url = UrlBLL.Table.FirstOrDefault(o => o.EntityName == "Category" && o.EntityId == obj.Id);
             url.Slug = obj.ValidateSeName("", obj.Name, true);
             UrlBLL.Update(url);
             CateBLL.Update(model);
             CacheManager.Remove(Consts.CategoryCacheKey);
             CacheManager.Remove(Consts.UrlRecordCacheKey);
             return(Json(true, JsonRequestBehavior.AllowGet));
         }
     }
 }
Пример #2
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            long   id   = long.Parse(Request.QueryString["id"].ToString());
            var    old  = cateBLL.getByID(id);
            string path = old.ImagePath;

            if (txtName.Text != "")
            {
                if (img_upload.HasFile)
                {
                    path = "/assets/upload/images/category/" + img_upload.FileName;
                    cateBLL.Update(
                        new Category()
                    {
                        ID               = id,
                        Name             = txtName.Text,
                        Description      = txtDesc.Text,
                        ImagePath        = path,
                        Meta_Description = txtMetaDesc.Text,
                        Meta_Keyword     = txtKeyword.Text,
                        Status           = rblStatus.SelectedValue == "1" ? true : false
                    });

                    img_upload.SaveAs(Server.MapPath(path));
                }
                else
                {
                    cateBLL.Update(
                        new Category()
                    {
                        ID               = id,
                        Name             = txtName.Text,
                        Description      = txtDesc.Text,
                        ImagePath        = path,
                        Meta_Description = txtMetaDesc.Text,
                        Meta_Keyword     = txtKeyword.Text,
                        Status           = rblStatus.SelectedValue == "1" ? true : false
                    });
                }
            }
        }