Beispiel #1
0
 public void Insert(List <ActiveUp.Net.Common.DeltaExt.Action> entity)
 {
     using (var dbcontext = new FAXPECContext())
     {
         using (var transaction = dbcontext.Database.BeginTransaction())
         {
             foreach (ActiveUp.Net.Common.DeltaExt.Action a in entity)
             {
                 try
                 {
                     ACTIONS action = DaoSQLServerDBHelper.MapToActionDto(a, true);
                     dbcontext.ACTIONS.Add(action);
                     dbcontext.SaveChanges();
                     a.Id = (decimal)dbcontext.ACTIONS.Select(x => x.ID).DefaultIfEmpty(0).Max();
                 }
                 catch (Exception ex)
                 {
                     transaction.Rollback();
                     if (ex.GetType() == typeof(ManagedException))
                     {
                         ManagedException mEx = new ManagedException(ex.Message, "ACT_ORA004", string.Empty, string.Empty, ex);
                         ErrorLogInfo     er  = new ErrorLogInfo(mEx);
                         log.Error(er);
                         throw mEx;
                     }
                 }
             }
             transaction.Commit();
         }
     }
 }
Beispiel #2
0
 public void Update(ActiveUp.Net.Common.DeltaExt.Action entity)
 {
     using (var dbcontext = new FAXPECContext())
     {
         try
         {
             var action = dbcontext.ACTIONS.Where(x => x.ID == (double)entity.Id).FirstOrDefault();
             action = DaoSQLServerDBHelper.MapToActionDto(entity, false);
             int resp = dbcontext.SaveChanges();
             if (resp == 0)
             {
                 throw new Exception("Nessun record aggiornato");
             }
         }
         catch (Exception ex)
         {
             if (ex.GetType() == typeof(ManagedException))
             {
                 ManagedException mEx = new ManagedException(ex.Message, "ACT_ORA002", string.Empty, string.Empty, ex);
                 ErrorLogInfo     er  = new ErrorLogInfo(mEx);
                 log.Error(er);
                 throw mEx;
             }
         }
     }
 }
Beispiel #3
0
 public void Insert(ActiveUp.Net.Common.DeltaExt.Action entity)
 {
     using (var dbcontext = new FAXPECContext())
     {
         try
         {
             ACTIONS action = DaoSQLServerDBHelper.MapToActionDto(entity, true);
             dbcontext.ACTIONS.Add(action);
         }
         catch (Exception ex)
         {
             if (ex.GetType() == typeof(ManagedException))
             {
                 ManagedException mEx = new ManagedException(ex.Message, "ACT_ORA001", string.Empty, string.Empty, ex);
                 ErrorLogInfo     er  = new ErrorLogInfo(mEx);
                 log.Error(er);
                 throw mEx;
             }
         }
     }
 }