Esempio n. 1
0
 public void Insert(List <ActionFolder> af)
 {
     using (var dbcontext = new FAXPECContext())
     {
         using (var transaction = dbcontext.Database.BeginTransaction())
         {
             foreach (ActionFolder a in af)
             {
                 try
                 {
                     ACTIONS_FOLDERS actionFolder = DaoSQLServerDBHelper.MapToActionFolder(a, true);
                     dbcontext.ACTIONS_FOLDERS.Add(actionFolder);
                     dbcontext.SaveChanges();
                     a.iD = (double)dbcontext.ACTIONS_FOLDERS.Select(x => x.ID).DefaultIfEmpty(0).Max();
                 }
                 catch (Exception ex)
                 {
                     transaction.Rollback();
                     if (ex.GetType() == typeof(ManagedException))
                     {
                         ManagedException mEx = new ManagedException(ex.Message, "ACF_ORA001", string.Empty, string.Empty, ex);
                         ErrorLogInfo     er  = new ErrorLogInfo(mEx);
                         log.Error(er);
                         throw mEx;
                     }
                 }
             }
             transaction.Commit();
         }
     }
 }