Example #1
0
        public void GuardarSubGerencia(SubGerencia entidad)
        {
            DataBaseModelContext db = new DataBaseModelContext();

            try
            {
                entidad.Descripcion = entidad.Descripcion.ToUpper();
                db.ContextOptions.ProxyCreationEnabled = _proxy;
                //TODO: Cambiar habilitado por el embebido
                entidad.Habilitado = true;
                if (entidad.Id == 0)
                {
                    db.SubGerencia.AddObject(entidad);
                }
                else
                {
                    SubGerencia tmpSubGerencia = db.SubGerencia.SingleOrDefault(s => s.Id == entidad.Id);
                    if (tmpSubGerencia == null)
                    {
                        return;
                    }
                    tmpSubGerencia.Descripcion = entidad.Descripcion;
                    tmpSubGerencia.Habilitado  = entidad.Habilitado;
                }
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception((ex.InnerException).Message);
            }
            finally
            {
                db.Dispose();
            }
        }
Example #2
0
 public void GuardarSubGerencia(SubGerencia entidad)
 {
     try
     {
         using (BusinessOrganizacion negocio = new BusinessOrganizacion())
         {
             negocio.GuardarSubGerencia(entidad);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }