Example #1
0
        private void IsExistsName(ISession session, Unit unit)
        {
            ICriteria criteria = session.CreateCriteria(typeof(Unit));

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

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

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.UnitNameIsExistsException();//单位名已经存在
            }
        }
Example #2
0
 public ActionResult Update(Unit unit)
 {
     return Json(unitOper.Update(unit,
         delegate(object sender, ISession session)
         {
             //判断是否存在部门Code
             IsExistsName(session, unit);
         }
         ));
 }
Example #3
0
 public ActionResult Del(Unit unit)
 {
     return Json(unitOper.Del(unit));
 }