public IHttpActionResult DelProductType(RequestDelProductType request) { var tokenResult = IdentityValid.ValidateToken(request.Token); if (!tokenResult.IsSuccess) { return(Json(tokenResult)); } var productTypeBll = new ProductTypeBLL(); var productBll = new ProductBLL(); if (productBll.IsExist(o => o.UserName == tokenResult.userName && o.ProductTypeId == request.ProductTypeId)) { return(Json(new ResponseMsg() { IsSuccess = false, Msg = "该物品类别下有物品,不可删除!" })); } if (productTypeBll.IsExist(o => o.ParentProductTypeId == request.ProductTypeId)) { return(Json(new ResponseMsg() { IsSuccess = false, Msg = "请先删除子类别!" })); } bool isSuccess = productTypeBll.Delete(o => o.UserName == tokenResult.userName && o.ProductTypeId == request.ProductTypeId); return(Json(new ResponseMsg() { IsSuccess = isSuccess })); }