Пример #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));
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         long id     = long.Parse(Request.QueryString["id"].ToString());
         bool result = new CateBLL().ChangedStatus(id);
         if (result == true)
         {
             Response.Write("1");
         }
         Response.Write("0");
     }
     catch { }
 }
Пример #3
0
 public ActionResult Delete(Guid id)
 {
     foreach (Guid gid in GetIdAndChildId(TableCache.Where(o => o.Id == id).ToList()))
     {
         Category  obj       = CateBLL.GetById(gid);
         UrlRecord urlRecord = UrlBLL.Table.FirstOrDefault(o => o.EntityName == "Category" && o.EntityId == obj.Id);
         if (urlRecord != null)
         {
             UrlBLL.Delete(urlRecord);
         }
         CateBLL.Delete(obj);
     }
     CacheManager.Remove(Consts.CategoryCacheKey);
     CacheManager.Remove(Consts.UrlRecordCacheKey);
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
Пример #4
0
 public ActionResult Add(Category obj)
 {
     if (string.IsNullOrEmpty(obj.Name))
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
     else
     {
         obj.Id = Guid.NewGuid();
         UrlRecord url = new UrlRecord
         {
             Id         = Guid.NewGuid(),
             EntityId   = obj.Id,
             EntityName = "Category",
             Slug       = obj.ValidateSeName("", obj.Name, true)
         };
         UrlBLL.Create(url);
         CateBLL.Create(obj);
         CacheManager.Remove(Consts.CategoryCacheKey);
         CacheManager.Remove(Consts.UrlRecordCacheKey);
         return(Json(true, JsonRequestBehavior.AllowGet));
     }
 }