Beispiel #1
0
 /// <summary>
 ///  创建模块集合
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="entitys">模块集合</param>
 /// <returns></returns>
 public bool EditCollection(ref ValidationErrors validationErrors, IQueryable <SysMenu> entitys)
 {
     if (entitys != null)
     {
         try
         {
             int flag = 0, count = entitys.Count();
             if (count > 0)
             {
                 using (TransactionScope transactionScope = new TransactionScope())
                 {
                     foreach (var entity in entitys)
                     {
                         if (Edit(ref validationErrors, db, entity))
                         {
                             flag++;
                         }
                         else
                         {
                             Transaction.Current.Rollback();
                             return(false);
                         }
                     }
                     if (count == flag)
                     {
                         transactionScope.Complete();
                         return(true);
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             validationErrors.Add(ex.Message);
             ExceptionsHander.WriteExceptions(ex);
         }
     }
     return(false);
 }
 /// <summary>
 ///  创建部门集合
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="entitys">部门集合</param>
 /// <returns></returns>
 public bool EditCollection(ref ValidationErrors validationErrors, IQueryable <SysDepartment> entitys)
 {
     try
     {
         if (entitys != null)
         {
             int count = entitys.Count();
             if (count == 1)
             {
                 return(this.Edit(ref validationErrors, entitys.FirstOrDefault()));
             }
             else if (count > 1)
             {
                 using (TransactionScope transactionScope = new TransactionScope())
                 {
                     repository.Edit(db, entitys);
                     if (count == repository.Save(db))
                     {
                         transactionScope.Complete();
                         return(true);
                     }
                     else
                     {
                         Transaction.Current.Rollback();
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
Beispiel #3
0
 /// <summary>
 /// 编辑一个模块
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="entity">一个模块</param>
 /// <returns>是否编辑成功</returns>
 public bool Edit(ref ValidationErrors validationErrors, SysMenu entity)
 {
     try
     {
         using (TransactionScope transactionScope = new TransactionScope())
         {
             if (Edit(ref validationErrors, db, entity))
             {
                 transactionScope.Complete();
                 return(true);
             }
             else
             {
                 Transaction.Current.Rollback();
             }
         }
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }