示例#1
0
 public void Insert(SendMail.Model.BackEndRefCode entity)
 {
     try
     {
         using (var dbcontext = new FAXPECContext())
         {
             RUBR_BACKEND r = AutoMapperConfiguration.FromRubrBackendToDto(entity);
             dbcontext.RUBR_BACKEND.Add(r);
             int risp = dbcontext.SaveChanges();
             if (risp != 1)
             {
                 throw new InvalidOperationException("Dato non inserito");
             }
         }
     }
     catch (Exception ex)
     {
         if (ex.GetType() != typeof(ManagedException))
         {
             ManagedException mEx = new ManagedException(ex.Message,
                                                         "ERR_ORADB111",
                                                         string.Empty,
                                                         string.Empty,
                                                         ex);
             ErrorLogInfo er = new ErrorLogInfo(mEx);
             log.Error(er);
             throw mEx;
         }
         else
         {
             throw;
         }
     }
 }
示例#2
0
        public SendMail.Model.BackEndRefCode GetById(decimal id)
        {
            BackEndRefCode entity = null;

            try
            {
                using (var dbcontext = new FAXPECContext())
                {
                    RUBR_BACKEND b = dbcontext.RUBR_BACKEND.Where(x => x.ID_BACKEND == id).First();
                    if (b != null && b.ID_BACKEND != 0)
                    {
                        entity = AutoMapperConfiguration.FromRubrBackendToSingleModel(b);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception e0)
            {
                if (e0.GetType() != typeof(ManagedException))
                {
                    ManagedException me  = new ManagedException(e0.Message, "ORA_ERR002", string.Empty, string.Empty, e0);
                    ErrorLogInfo     err = new ErrorLogInfo(me);
                    log.Error(err);
                }
                return(null);
            }
            return(entity);
        }
示例#3
0
        public void Delete(decimal id)
        {
            try
            {
                using (var dbcontext = new FAXPECContext())
                {
                    RUBR_BACKEND r = dbcontext.RUBR_BACKEND.Where(x => x.ID_BACKEND == id).First();
                    dbcontext.RUBR_BACKEND.Remove(r);
                    int resp = dbcontext.SaveChanges();
                    if (resp != 1)
                    {
                        throw new InvalidOperationException("Oggetto non cancellato");
                    }
                }
            }
            catch (Exception ex)
            {
                if (!ex.GetType().Equals(typeof(ManagedException)))
                {
                    ManagedException mEx = new ManagedException(ex.Message,
                                                                "ORA_ERR006", string.Empty, string.Empty, ex);
                    ErrorLogInfo err = new ErrorLogInfo(mEx);

                    log.Error(err);
                    throw mEx;
                }
                else
                {
                    throw ex;
                }
            }
        }
示例#4
0
        public BackEndRefCode GetByCode(string backendCode)
        {
            BackEndRefCode entity = null;

            try
            {
                using (var dbcontext = new FAXPECContext())
                {
                    RUBR_BACKEND b = dbcontext.RUBR_BACKEND.Where(x => x.BACKEND_CODE.ToUpper() == backendCode.ToUpper()).First();
                    if (b != null && b.ID_BACKEND != 0)
                    {
                        entity = AutoMapperConfiguration.FromRubrBackendToSingleModel(b);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch
            {
                return(null);
            }
            return(entity);
        }
示例#5
0
 public void Update(SendMail.Model.BackEndRefCode entity)
 {
     try
     {
         using (var dbcontext = new FAXPECContext())
         {
             RUBR_BACKEND b = dbcontext.RUBR_BACKEND.Where(x => x.ID_BACKEND == entity.Id).First();
             b = AutoMapperConfiguration.FromModelToRubrBackendDto(entity, b);
             int risp = dbcontext.SaveChanges();
             if (risp != 1)
             {
                 throw new InvalidOperationException("Oggetto non aggiornato");
             }
         }
     }
     catch (Exception e0)
     {
         if (e0.GetType() != typeof(ManagedException))
         {
             ManagedException me  = new ManagedException(e0.Message, "ORA_ERR022", string.Empty, string.Empty, e0);
             ErrorLogInfo     err = new ErrorLogInfo(me);
             log.Error(err);
         }
         throw;
     }
 }