コード例 #1
0
        private void IsExistsCode(ISession session, GoodsType goodsType)
        {
            ICriteria criteria = session.CreateCriteria(typeof(GoodsType));

            ICriterion criterion = null;
            if (goodsType.Id != Guid.Empty)
            {
                criterion = Restrictions.Not(Restrictions.IdEq(goodsType.Id));
                criteria.Add(criterion);
            }

            criterion = Restrictions.Eq("GoodsTypeCode", goodsType.GoodsTypeCode);
            criteria.Add(criterion);
            //统计
            criteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.Count("Id"))
                );

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.GoodsTypeCodeIsExistsException();//商品资料Code已经存在
            }
        }
コード例 #2
0
 public ActionResult Update(GoodsType goodsType)
 {
     return Json(goodsTypeOper.Update(goodsType,
         delegate(object sender, ISession session)
         {
             //判断是否存在商品资料Code
             IsExistsCode(session, goodsType);
         }
         ));
 }
コード例 #3
0
 public ActionResult Del(GoodsType goodsType)
 {
     return Json(goodsTypeOper.Del(goodsType));
 }