Example #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;
         }
     }
 }
Example #2
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;
     }
 }
Example #3
0
 public SendMail.Model.BackEndRefCode insertTitolo(SendMail.Model.BackEndRefCode e)
 {
     throw new NotImplementedException();
 }
Example #4
0
 public SendMail.Model.BackEndRefCode Update(SendMail.Model.BackEndRefCode e)
 {
     throw new NotImplementedException();
 }
Example #5
0
 public void Update(SendMail.Model.BackEndRefCode entity)
 {
     try
     {
         using (OracleCommand cmd = CurrentConnection.CreateCommand())
         {
             StringBuilder sb = new StringBuilder("UPDATE rubr_backend SET")
                                .Append(" backend_code = :p_code, backend_descr = :p_descr")
                                .Append(", category = :p_cat, descr_plus = :p_descrp")
                                .Append(" WHERE id_backend = :p_id");
             cmd.CommandText = sb.ToString();
             cmd.BindByName  = true;
             cmd.Parameters.Add(new OracleParameter
             {
                 Direction     = ParameterDirection.Input,
                 OracleDbType  = OracleDbType.Varchar2,
                 ParameterName = "p_code",
                 Size          = 15,
                 Value         = entity.Codice
             });
             cmd.Parameters.Add(new OracleParameter
             {
                 Direction     = ParameterDirection.Input,
                 OracleDbType  = OracleDbType.Varchar2,
                 ParameterName = "p_descr",
                 Size          = 100,
                 Value         = entity.Descrizione
             });
             cmd.Parameters.Add(new OracleParameter
             {
                 Direction     = ParameterDirection.Input,
                 OracleDbType  = OracleDbType.NVarchar2,
                 ParameterName = "p_cat",
                 Size          = 40,
                 Value         = entity.Categoria
             });
             cmd.Parameters.Add(new OracleParameter
             {
                 Direction     = ParameterDirection.Input,
                 OracleDbType  = OracleDbType.Varchar2,
                 ParameterName = "p_descrp",
                 Size          = 10,
                 Value         = entity.DescrizionePlus
             });
             cmd.Parameters.Add(new OracleParameter
             {
                 Direction     = ParameterDirection.Input,
                 OracleDbType  = OracleDbType.Decimal,
                 ParameterName = "p_id",
                 Precision     = 10,
                 Scale         = 0,
                 Value         = entity.Id
             });
             int risp = cmd.ExecuteNonQuery();
             if (risp != 1)
             {
                 throw new InvalidOperationException("Oggetto non aggiornato");
             }
         }
     }
     catch
     {
         throw;
     }
 }
Example #6
0
 public void Insert(SendMail.Model.BackEndRefCode entity)
 {
     try
     {
         using (OracleCommand cmd = CurrentConnection.CreateCommand())
         {
             StringBuilder sb = new StringBuilder("INSERT INTO rubr_backend")
                                .Append(" (backend_code, backend_descr, category, descr_plus)")
                                .Append(" VALUES")
                                .Append(" (:p_code, :p_descr, :p_cat, :p_descrp)")
                                .Append(" RETURNING id_backend INTO :p_id");
             cmd.CommandText = sb.ToString();
             cmd.BindByName  = true;
             cmd.Parameters.Add(new OracleParameter
             {
                 Direction     = ParameterDirection.Input,
                 OracleDbType  = OracleDbType.Varchar2,
                 ParameterName = "p_code",
                 Size          = 15,
                 Value         = entity.Codice
             });
             cmd.Parameters.Add(new OracleParameter
             {
                 Direction     = ParameterDirection.Input,
                 OracleDbType  = OracleDbType.Varchar2,
                 ParameterName = "p_descr",
                 Size          = 100,
                 Value         = entity.Descrizione
             });
             cmd.Parameters.Add(new OracleParameter
             {
                 Direction     = ParameterDirection.Input,
                 OracleDbType  = OracleDbType.NVarchar2,
                 ParameterName = "p_cat",
                 Size          = 40,
                 Value         = entity.Categoria
             });
             cmd.Parameters.Add(new OracleParameter
             {
                 Direction     = ParameterDirection.Input,
                 OracleDbType  = OracleDbType.Varchar2,
                 ParameterName = "p_descrp",
                 Size          = 10,
                 Value         = entity.DescrizionePlus
             });
             cmd.Parameters.Add(new OracleParameter
             {
                 Direction     = ParameterDirection.Output,
                 OracleDbType  = OracleDbType.Decimal,
                 ParameterName = "p_id",
                 Precision     = 10,
                 Scale         = 0
             });
             int risp = cmd.ExecuteNonQuery();
             if (risp != 1)
             {
                 throw new InvalidOperationException("Dato non inserito");
             }
             entity.Id = ((OracleDecimal)cmd.Parameters["p_id"].Value).Value;
         }
     }
     catch (Exception ex)
     {
         //Allineamento log - Ciro
         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;
         }
     }
 }
Example #7
0
 public BackEndRefCode Save(BackEndRefCode e)
 {
     return(e);
 }