Exemple #1
0
 public JsonResult AddCategory()
 {
     JsonResult res = new JsonResult();
     JsonMessage message = new JsonMessage() { Status="ok"};
     User user = (User)Session["User"];
     ShopManager shopMgr = new ShopManager(user);
     string name = Request["name"];
     string pid = Request["pid"];
     int parentId = 0;
     int.TryParse(pid,out parentId);
     if (string.IsNullOrEmpty(name))
     {
         message.Status = "failed";
         message.Message = "类目名称不能为空";
     }
     else
     {
         if (shopMgr.IsCategoryExist(parentId, name))
         {
             message.Status = "failed";
             message.Message = "类目名称已经存在";
             res.Data = message;
         }
         else
         {
             Category cate = shopMgr.CreateCategory(parentId, name);
             message.Item = cate;
             res.Data = message;
         }
     }
     return res;
 }