示例#1
0
        public UsuariosArtista CargarPorIdAlbum(int idAlbum)
        {
            UsuariosArtista artistaCargado = new UsuariosArtista();

            using (UVFYContext context = new UVFYContext())
            {
                try
                {
                    artistaCargado = context.UsuariosArtista.FirstOrDefault(a => a.Albumes.Any(b => b.Id == idAlbum));
                }
                catch (SqlException e)
                {
                    Console.WriteLine(e.ToString());
                    throw new AccesoADatosException(e.Message, e);
                }
                if (artistaCargado == null)
                {
                    throw new RecursoNoExisteException();
                }
            }
            return(artistaCargado);
        }
示例#2
0
        public UsuariosArtista CargarPorId(int idArtista)
        {
            UsuariosArtista artistaCargado = new UsuariosArtista();

            using (UVFYContext context = new UVFYContext())
            {
                try
                {
                    artistaCargado = context.UsuariosArtista.Find(idArtista);
                }
                catch (SqlException e)
                {
                    Console.WriteLine(e.ToString());
                    throw new AccesoADatosException(e.Message, e);
                }
                if (artistaCargado == null)
                {
                    throw new RecursoNoExisteException();
                }
            }
            return(artistaCargado);
        }