private async Task <bool> CargarAlbumDeCanciones(List <Cancion> canciones) { AlbumDAO albumDAO = new AlbumDAO(Token); foreach (Cancion cancion in canciones) { if (cancion.Album != null) { Album respuesta; try { respuesta = await albumDAO.CargarPorId(cancion.Album.Id); } catch (Exception ex) { MensajeDeErrorParaMessageBox mensaje = EncadenadorDeExcepciones.ManejarExcepcion(ex); MessageBox.Show(mensaje.Mensaje, mensaje.Titulo); return(false); } cancion.Album = respuesta; } } return(true); }
// GET: Home public ActionResult Index() { //Danh Sach Tat Ca Bai Hat BaiHatDAO bh = new BaiHatDAO(); List <BaiHat> ls = bh.ListOf(); ViewBag.NgheGanDay = ls; //Top 15 bai hat hay nhat var top15 = bh.Top15(); ViewBag.Top15 = top15; //Nghệ Sĩ Nổi Bật NgheSiDAO ns = new NgheSiDAO(); var NgheSiHot = ns.ListNgheSiHot(); ViewBag.NgheSiNoiBat = NgheSiHot; //BaiHatMoiPhatHanh var mph = bh.MoiPhatHanh(); ViewBag.MoiPhatHanh = mph; //Album Hot AlbumDAO al = new AlbumDAO(); var album = al.AlbumHot(); ViewBag.AlbumHot = album; //Thể Loại TheLoaiDAO tl = new TheLoaiDAO(); var theloai = tl.TheLoaiListIEnnumable(); ViewBag.TheLoai = theloai; return(View()); }
public ActionResult Upload(int id) { AlbumDAO dao = new AlbumDAO(); var ab = dao.Detail(id); return(View(ab)); }
private async void ButtonGuardar_Click(object sender, RoutedEventArgs e) { if (ValidarCampos()) { byte[] datosDeCaratula = ServiciosDeIO.CargarBytesDeArchivo(DireccionDeArchivoDeCaratula); foreach (Genero item in DataGridGeneros.ItemsSource) { if (((CheckBox)CheckBoxColumn.GetCellContent(item)).IsChecked == true) { GenerosSeleccionados.Add(item.Id); } } AlbumDAO albumDAO = new AlbumDAO(UsuarioActual.Token); try { bool resultado = await albumDAO.RegistrarAlbum(TextBoxNombreDeAlbum.Text, TextBoxDescripcionDeAlbum.Text, GenerosSeleccionados, datosDeCaratula); } catch (Exception ex) { MensajeDeErrorParaMessageBox mensaje = EncadenadorDeExcepciones.ManejarExcepcion(ex); MessageBox.Show(mensaje.Mensaje, mensaje.Titulo); } GenerosSeleccionados = new List <int>(); } else { } }
public ActionResult Upload(HttpPostedFileBase file, Album obj) { try { if (file != null && file.ContentLength > 0) { string fileName = Path.GetFileNameWithoutExtension(file.FileName); fileName += "_" + obj.IdAlbum; fileName += Path.GetExtension(file.FileName); string folderPath = Server.MapPath("~") + @"\Assets\images\ImagesOutSource\ImagesSong"; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } string path = Path.Combine(folderPath, fileName); file.SaveAs(path); var dao = new AlbumDAO(); dao.Upload(obj.IdAlbum, fileName); } else { ModelState.AddModelError("", "Bạn phải nhập vào trường này"); } } catch (System.Exception) { return(View(obj)); } return(View()); }
public void create() { AlbumDTO aDTO = new AlbumDTO(name, releaseYear, genre, interpret, coverpath); AlbumDAO aDAO = new AlbumDAO(); aDAO.insertAlbum(aDTO); }
private async void MostrarAlbumesDeArtista(Artista artista) { AlbumDAO albumDAO = new AlbumDAO(UsuarioActual.Token); List <Album> respuesta; try { respuesta = await albumDAO.CargarPorIdArtista(artista.Id); } catch (Exception ex) { MensajeDeErrorParaMessageBox mensaje = EncadenadorDeExcepciones.ManejarExcepcion(ex); MessageBox.Show(mensaje.Mensaje, mensaje.Titulo); return; } if (respuesta.Count == 1 && respuesta[0].Id == 0) { ListaDeAlbumesDeArtista.Visibility = Visibility.Collapsed; LabelNoHayAlbumesDeArtista.Visibility = Visibility.Visible; ListaDeCancionesDeArtista.Visibility = Visibility.Collapsed; LabelNoHayCancionesDeAlbum.Visibility = Visibility.Collapsed; } else { ListaDeAlbumesDeArtista.Visibility = Visibility.Visible; LabelNoHayAlbumesDeArtista.Visibility = Visibility.Collapsed; ListaDeAlbumesDeArtista.AsignarAlbumes(respuesta); } }
public void loadData() { if (a.username != null && a.username != "") { lbName.Visible = true; lbName.Text = "Hello, " + a.firstname + " " + a.lastname; } else { lbName.Visible = false; } check++; try { if (check > 4) { int genreid = int.Parse(comboBox1.SelectedValue.ToString()); int artistid = int.Parse(comboBox2.SelectedValue.ToString()); DataTable dt = AlbumDAO.GetAlbum(genreid, artistid); dataGridView1.AutoGenerateColumns = false; dataGridView1.DataSource = dt; } } catch (Exception ex) { return; } }
public List <SongDTO> getAllSongsByAlbum(string album) { SongDAO sDAO = new SongDAO(); AlbumDAO aDAO = new AlbumDAO(); return(sDAO.getAllFromDbByAlbumId(aDAO.getIdFromDb(album))); }
private async void ButtonAgregarCancionAAlbum_Click(object sender, RoutedEventArgs e) { Album albumSeleccionado = (Album)DataGridListaDeAlbumes.SelectedItem; if (albumSeleccionado != null) { Cancion cancionSeleccionada = ((FrameworkElement)sender).DataContext as Cancion; AlbumDAO albumDAO = new AlbumDAO(Artista.Token); try { bool resultado = await albumDAO.AgregarCancionAAlbum(albumSeleccionado.Id, cancionSeleccionada.Id); CargarDatos(); } catch (Exception ex) { MensajeDeErrorParaMessageBox mensaje = EncadenadorDeExcepciones.ManejarExcepcion(ex); MessageBox.Show(mensaje.Mensaje, mensaje.Titulo); } } else { MessageBox.Show("Debe elegir un album", "Ningun album seleccionado"); } }
public ActionResult Update(Album obj, HttpPostedFileBase file) { AlbumDAO dao = new AlbumDAO(); if (file != null && file.ContentLength > 0) { string fileName = Path.GetFileNameWithoutExtension(file.FileName); fileName += "_" + obj.IdAlbum; fileName += Path.GetExtension(file.FileName); string folderPath = Server.MapPath("~") + @"\Assets\images\ImagesOutSource\ImagesSong"; string folderPath2 = Server.MapPath("~") + @"\Assets\images\ImagesOutSource\Album"; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } string path = Path.Combine(folderPath, fileName); string path2 = Path.Combine(folderPath2, fileName); file.SaveAs(path); file.SaveAs(path2); obj.AnhAlbum = fileName; if (dao.UpdateAlbum(obj)) { return(RedirectToAction("Index", "Album")); } else { ModelState.AddModelError("", "Error"); return(View(obj.IdAlbum)); } } else { ModelState.AddModelError("", "Bạn phải nhập vào trường này"); } NgheSiDAO nsDAO = new NgheSiDAO(); var ns = nsDAO.Listof(); KhuVucDAO kvDAO = new KhuVucDAO(); var kv = kvDAO.ListOf(); ViewBag.ns = ns; ViewBag.kv = kv; return(View()); //try //{ // AlbumDAO dao = new AlbumDAO(); // if (dao.UpdateAlbum(ab)) // { // return RedirectToAction("Index", "Album"); // } // else // { // ModelState.AddModelError("", "Error"); // return View(ab.IdAlbum); // } }
public ActionResult TatCaAlbum() { AlbumDAO al = new AlbumDAO(); //Tất cả album var allAlbum = al.Listof(); return(View(allAlbum)); }
// GET: Admin/Album public ActionResult Index() { AlbumDAO dao = new AlbumDAO(); var result = dao.Listof(); return(View(result)); }
public ActionResult DeleteAlbum(int id) { AlbumDAO dao = new AlbumDAO(); dao.DeleteAlbum(id); return(RedirectToAction("Index", "Album")); }
public ActionResult Update(BaiHat obj, HttpPostedFileBase file, FormCollection f) { BaiHatDAO dao = new BaiHatDAO(); try { if (file != null && file.ContentLength > 0) { string fileName = Path.GetFileNameWithoutExtension(file.FileName); fileName += "_" + obj.IdBaiHat; fileName += Path.GetExtension(file.FileName); string folderPath = Server.MapPath("~") + @"\Areas\Admin\Asset\ImagesOutSource\imgsong"; string folderPath2 = Server.MapPath("~") + @"/Assets/images/ImagesOutSource/ImagesSong"; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } string path = Path.Combine(folderPath, fileName); string path2 = Path.Combine(folderPath2, fileName); file.SaveAs(path); file.SaveAs(path2); obj.AnhBaiHat = fileName; obj.IdNgheSi = Convert.ToInt32(f["getNgheSi"]); if (dao.Update(obj)) { return(RedirectToAction("Index", "AdBaiHat")); } else { ModelState.AddModelError("", "Error"); return(View(obj.IdBaiHat)); } } else { ModelState.AddModelError("", "Bạn phải nhập vào trường này"); } } catch { } TheLoaiDAO tldao = new TheLoaiDAO(); var category = tldao.ListOf(); NgheSiDAO nsdao = new NgheSiDAO(); var nghesi = nsdao.Listof(); AlbumDAO abdao = new AlbumDAO(); var album = abdao.Listof(); ViewBag.category = category; ViewBag.nghesi = nghesi; ViewBag.album = album; return(View()); }
public PhotosController() { //Creating Dependencies using connection string. string connectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; dataAccess = new PhotosDAO(connectionString); albumData = new AlbumDAO(connectionString); exceptionLog = new ExceptionHandler(connectionString); }
public List <String> getAlbumsByInterpret(string interpret) { List <String> albums = new List <String>(); AlbumDAO aDAO = new AlbumDAO(); InterpretDAO iDAO = new InterpretDAO(); albums = aDAO.getAllByInterpret(iDAO.getIdFromDb(interpret)); return(albums); }
public ActionResult AlbumDetail(int id) { AlbumDAO al = new AlbumDAO(); var album = al.Detail(id); BaiHatDAO bh = new BaiHatDAO(); ViewBag.BaiHatTheoAlbum = bh.BaiHatTheoAlbum(id); return(View(album)); }
public AlbumController() { string connectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; dataAccess = new AlbumDAO(connectionString); userData = new UserDAO(connectionString); allPhotos = new PhotosDAO(connectionString); exceptionLog = new ExceptionHandler(connectionString); }
public Song(string name, string trackNo, string duration, string songtext, string album) { AlbumDAO aDAO = new AlbumDAO(); this.name = name; this.trackNo = trackNo; this.duration = duration; this.songtext = songtext; this.album = aDAO.getIdFromDb(album); }
public JsonResult Get(int AlbumId, int PerfilId, string Titulo = "") { Album album = AlbumDAO.Get(AlbumId, PerfilId, Titulo).FirstOrDefault(); var a = new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { Datos = album /*, Tags = LTag */ } }; return(a); }
public ActionResult Index(int?page) { var dummyItems = AlbumDAO.Get(0, 0, ""); var pager = new Pager(dummyItems.Count(), page); var viewModel = new IndexViewModel { AlbumP = dummyItems.Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize), Pager = pager }; return(View(viewModel)); }
public override Task <Respuesta> GuardarCaratulaDeAlbumPorId(PeticionGuardadoId request, ServerCallContext context) { Respuesta respuesta = new Respuesta(); try { using (UVFYContext contexto = new UVFYContext()) { AlbumDAO albumDAO = new AlbumDAO(); if (albumDAO.CargarPorId(request.IdPeticion) != null) { try { if (ServiciosDeIO.VerificarEstructuraDeArchivosAlbum()) { ServiciosDeIO.GuardarCaratulaDeAlbum(request.IdPeticion.ToString(), request.Datos.ToByteArray()); respuesta.Exitosa = true; } else { //No se pudo realizar el guardado, error de io respuesta.Exitosa = false; respuesta.Motivo = 500; } } catch (IOException) { //No se pudo realizar el guardado, error de io respuesta.Exitosa = false; respuesta.Motivo = 500; } } else { //No se encontro la cancion con el id dado (Deberia ser imposible porque se valida) respuesta.Exitosa = false; respuesta.Motivo = 400; } } } catch (AccesoADatosException) { //Error conectandose a la base de datos respuesta.Exitosa = false; respuesta.Motivo = 500; return(Task.FromResult(respuesta)); } return(Task.FromResult(respuesta)); }
public void delete(string name) { FunctionController fc = new FunctionController(); AlbumDAO aDAO = new AlbumDAO(); List <SongDTO> songs = new List <SongDTO>(); songs = fc.getAllSongsByAlbum(name); foreach (SongDTO song in songs) { Song s = new Song(song.getName(), "", "", "", ""); s.delete(song.getName()); } aDAO.deleteAlbum(name); }
public ActionResult Update(int id) { AlbumDAO dao = new AlbumDAO(); NgheSiDAO nsDAO = new NgheSiDAO(); var ns = nsDAO.Listof(); KhuVucDAO kvDAO = new KhuVucDAO(); var kv = kvDAO.ListOf(); ViewBag.ns = ns; ViewBag.kv = kv; var up = dao.Detail(id); return(View(up)); }
public ActionResult Add() { TheLoaiDAO tldao = new TheLoaiDAO(); var category = tldao.ListOf(); NgheSiDAO nsdao = new NgheSiDAO(); var nghesi = nsdao.Listof(); AlbumDAO abdao = new AlbumDAO(); var album = abdao.Listof(); ViewBag.category = category; ViewBag.nghesi = nghesi; ViewBag.album = album; return(View()); }
public ActionResult Update(int id) { TheLoaiDAO tldao = new TheLoaiDAO(); var category = tldao.ListOf(); NgheSiDAO nsdao = new NgheSiDAO(); var nghesi = nsdao.Listof(); AlbumDAO abdao = new AlbumDAO(); var album = abdao.Listof(); ViewBag.category = category; ViewBag.nghesi = nghesi; ViewBag.album = album; BaiHatDAO dao = new BaiHatDAO(); var rs = dao.Detail(id); return(View(rs)); }
// GET: Album public ActionResult Index() { AlbumDAO al = new AlbumDAO(); //Tất cả album var allAlbum = al.Listof(); ViewBag.TatCaAlbum = allAlbum; //Album Hot var albumHot = al.AlbumHot(); ViewBag.AlbumHot = albumHot; //Bai hát Theo Album var listBh = al.BaiHatByAlbum(); ViewBag.BaiHatTheoAlbum = listBh; return(View()); }
private async void CargarDatos() { try { CancionDAO cancionDAO = new CancionDAO(Artista.Token); AlbumDAO albumDAO = new AlbumDAO(Artista.Token); AlbumesCargados = await albumDAO.CargarPorIdArtista(Artista.Id); CancionesPrivadas = await cancionDAO.CargarPrivadasPorIdArtista(Artista.Id); } catch (Exception ex) { MensajeDeErrorParaMessageBox mensaje = EncadenadorDeExcepciones.ManejarExcepcion(ex); MessageBox.Show(mensaje.Mensaje, mensaje.Titulo); } if (AlbumesCargados.Count == 1 && AlbumesCargados[0].Id == 0) { DataGridListaDeAlbumes.Visibility = Visibility.Collapsed; LabelNoHayAlbumes.Visibility = Visibility.Visible; } else { DataGridListaDeAlbumes.Visibility = Visibility.Visible; LabelNoHayAlbumes.Visibility = Visibility.Collapsed; } if (CancionesPrivadas.Count == 1 && CancionesPrivadas[0].Id == 0) { DataGridListaDeCancionesSinAlbum.Visibility = Visibility.Collapsed; LabelNoHayCancionesPrivadas.Visibility = Visibility.Visible; } else { DataGridListaDeCancionesSinAlbum.Visibility = Visibility.Visible; LabelNoHayCancionesPrivadas.Visibility = Visibility.Collapsed; } DataGridListaDeAlbumes.ItemsSource = AlbumesCargados; DataGridListaDeCancionesSinAlbum.ItemsSource = CancionesPrivadas; if (DataGridListaDeAlbumes.Items.Count > 0) { DataGridListaDeAlbumes.SelectedItem = DataGridListaDeAlbumes.Items[0]; } }
private async void ButtonEliminarAlbum_Click(object sender, RoutedEventArgs e) { if ((DataGridListaDeCancionesEnAlbum.Items[0] as Cancion).Id == 0 && DataGridListaDeCancionesEnAlbum.Items.Count == 1) { Album albumSeleccionado = ((FrameworkElement)sender).DataContext as Album; AlbumDAO albumDAO = new AlbumDAO(Artista.Token); try { bool resultado = await albumDAO.Eliminar(albumSeleccionado.Id); CargarDatos(); } catch (Exception ex) { MensajeDeErrorParaMessageBox mensaje = EncadenadorDeExcepciones.ManejarExcepcion(ex); MessageBox.Show(mensaje.Mensaje, mensaje.Titulo); } } else { MessageBox.Show("Vacie el album de canciones e intentelo nuevamente", "No puede eliminar un álbum vacio"); } }