Ejemplo n.º 1
0
 public AreaEntity Update(AreaEntity entity)
 {
     try
     {
         _areaRepository.Update(entity);
         return entity;
     }
     catch (Exception e)
     {
         _log.Error(e,"数据库操作出错");
         return null;
     }
 }
Ejemplo n.º 2
0
 public bool Delete(AreaEntity entity)
 {
     try
     {
         _areaRepository.Delete(entity);
         return true;
     }
     catch (Exception e)
     {
         _log.Error(e,"数据库操作出错");
         return false;
     }
 }
Ejemplo n.º 3
0
 public HttpResponseMessage AddArea([FromBody]AreaModel model)
 {
     Regex reg = new Regex(@"^[^ %@#!*~&',;=?$\x22]+$");
     var m = reg.IsMatch(model.AreaName);
     if (!m)
     {
         return PageHelper.toJson(PageHelper.ReturnValue(false, "存在非法字符!"));
     }
     else
     {
         AreaEntity fatherArea = _areaService.GetAreaById(model.Id);
         int Level = 1;
         int parentId = 0;
         if (fatherArea != null) //有上级分类则次级排序加1;
         {
             Level = fatherArea.Level + 1;
             parentId = fatherArea.Id;
         }
         AreaEntity ce = new AreaEntity()
         {
             AreaName = model.AreaName,
             Level = Level,
             ParentId = parentId
         };
         try
         {
             _areaService.Create(ce);
             return PageHelper.toJson(PageHelper.ReturnValue(true, "添加成功!"));
         }
         catch (Exception error)
         {
             return PageHelper.toJson(PageHelper.ReturnValue(false, "添加失败!"));
             ;
         }
     }
 }