コード例 #1
0
 public bool AddMenu(Guid userId, List <Guid> menulist)
 {
     try
     {
         this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
         var userMenuBO = new UserMenuBO();
         foreach (var guid in menulist)
         {
             var userMenu = userMenuBO.Get(this.ConnectionHandler, userId, guid);
             if (userMenu == null)
             {
                 var userOperation = new UserMenu {
                     UserId = userId, MenuId = guid
                 };
                 if (!userMenuBO.Insert(this.ConnectionHandler, userOperation))
                 {
                     throw new Exception("خطایی در ذخیره  منوی کاربر  وجود دارد");
                 }
             }
         }
         this.ConnectionHandler.CommitTransaction();
         return(true);
     }
     catch (KnownException ex)
     {
         this.ConnectionHandler.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
     catch (Exception ex)
     {
         this.ConnectionHandler.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
 }