Пример #1
0
 public ActionResult deletegoodstype(int id)
 {
     try
     {
         goodstypetemp model = db.goodstypetemp.FirstOrDefault(s => s.ID == id);
         if (model == null)
         {
             return(Json(Comm.ToJsonResult("NotFind", "商品分类不存在"), JsonRequestBehavior.AllowGet));
         }
         else
         {
             db.goodstypetemp.Remove(model);
             db.SaveChanges();
             return(Json(Comm.ToJsonResult("Success", "删除成功"), JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         return(Json(Comm.ToJsonResult("Error", ex.Message), JsonRequestBehavior.AllowGet));
     }
 }
Пример #2
0
 public ActionResult addgoodstype(int goodsid, int goodstypeid)
 {
     try
     {
         goodstypetemp model = db.goodstypetemp.FirstOrDefault(s => s.goodsid == goodsid && s.goodstypeid == goodstypeid);
         if (model != null)
         {
             return(Json(Comm.ToJsonResult("Exist", "该商品已经添加了此分类"), JsonRequestBehavior.AllowGet));
         }
         else
         {
             goodstypetemp tempmodel = new goodstypetemp();
             tempmodel.goodstypeid = goodstypeid;
             tempmodel.goodsid     = goodsid;
             db.goodstypetemp.Add(tempmodel);
             db.SaveChanges();
             return(Json(Comm.ToJsonResult("Success", "成功"), JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         return(Json(Comm.ToJsonResult("Error", ex.Message), JsonRequestBehavior.AllowGet));
     }
 }