public void ToModel(album a) { ArtistID = a.artist_id; AlbumName = a.albumName; AlbumID = a.id; GenreID = a.genre_id; }
public void add_sample_data(ChinookDbContext db) { var digital_download = new media_type() { Name = "Digital Download" }; var rock_genre = new genre() { Name = "Rock" }; var new_artist = new artist() { Name = "Bob Sacamano" }; var new_album = new album() { Title = "My stuff 2018", Artist = new_artist }; var new_track = new track() { Name = "Bad Medicine", Album = new_album, Genre = rock_genre, MediaType = digital_download }; var new_playlist = new playlist() { PlaylistId = 0, Name = "Test playlist" }; var ref_playlist_track = new playlist_track() { playlist = new_playlist, track = new_track }; new_playlist.tracks.Add(ref_playlist_track); db.playlist_tracks.Add(ref_playlist_track); db.SaveChanges(); }
public async Task <ActionResult> Edit([Bind(Include = "album_id,singer_id,album_name,album_createdate,album_image")] album album, HttpPostedFileBase Upload) { if (ModelState.IsValid) { var path = ""; var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { string _FileName = Path.GetFileName(file.FileName); string _Ext = Path.GetExtension(file.FileName); path = Path.Combine(Server.MapPath("~/source/images/"), _FileName); // Kiễm tra tồn tại file. if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } album.album_image = "~/source/images/" + _FileName; album.album_createdate = DateTime.Now; Upload.SaveAs(path); } db.Entry(album).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.singer_id = new SelectList(db.singers, "singer_id", "singer_name", album.singer_id); return(View()); }
public ActionResult Alterar(int id, album collection) { try { // TODO: Add update logic here if (ModelState.IsValid) { var albumObj = collection; string imgPath = Server.MapPath("/Content/"); var postedFile = Request.Files[0]; if (postedFile != null && postedFile.InputStream.Length > 0) { Stream foto = postedFile.InputStream; albumObj = _albumService.SalvarThumbnail(foto, imgPath, albumObj); } _albumService.UpdateAlbum(albumObj); return RedirectToAction("Index"); } return View(collection); } catch { return View(); } }
public IActionResult ListAlbumPhoto(string albumCode) { album album = _context.album.SingleOrDefault(m => m.album_code == albumCode); var abName = album.album_name; var abDesc = album.album_desc; var uploads = Path.Combine(_env.WebRootPath, _configuration.GetSection("Paths").GetSection("images_album").Value); uploads = Path.Combine(uploads, albumCode); string[] fileEntries = Directory.GetFiles(uploads); List <photo> p = new List <photo>(); string fiN; string fiP; foreach (string fileName in fileEntries) { fiN = Path.GetFileName(fileName); fiP = Path.Combine(albumCode, fiN); fiP = Path.Combine(_configuration.GetSection("Paths").GetSection("images_album").Value, fiP); p.Add(new photo { albumCode = albumCode, image_code = "", fileName = fiN, filePath = fiP, albumName = abName, albumDesc = abDesc }); } string pjson = JsonConvert.SerializeObject(p); //return Json(new { result = "success", uploads = uploads, photos = pjson }); return(Json(pjson)); }
// GET: albums public async Task <ViewResult> Index(string titleFilter, string userFilter, int?page) { int pageSize = 6; int pageIndex = 1; pageIndex = page.HasValue ? Convert.ToInt32(page) : 1; IPagedList <album> pagedAlbums = null; var albums = await myAlbums.Albums(); if (!string.IsNullOrEmpty(titleFilter)) { albums = albums.Where(a => a.title.Contains(titleFilter)); } if (!string.IsNullOrEmpty(userFilter)) { albums = albums.Where(a => a.user.name.Contains(userFilter)); } if (albums.Count() < 1) { var a = new album(); List <album> lA = new List <album>(); a.id = 1; a.title = "No Albums found matching entered criteria "; a.user = new user(); a.user.id = -1; a.user.name = " "; lA.Add(a); albums = lA.AsQueryable(); } pagedAlbums = albums.ToPagedList(pageIndex, pageSize); ViewBag.TitleFilter = " "; ViewBag.UserFilter = " "; return(View(pagedAlbums)); }
public async Task <ActionResult> Create([Bind(Include = "album_id,singer_id,album_name,album_createdate,album_image,album_view,album_viewed_day,album_viewed_week,album_viewed_month")] album album, HttpPostedFileBase Upload) { if (ModelState.IsValid) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { string _FileName = Path.GetFileName(file.FileName); string _Ext = Path.GetExtension(file.FileName); string path = Path.Combine(Server.MapPath("~/source/images/"), _FileName); album.album_image = "~/source/images/" + _FileName; Upload.SaveAs(path); } album.album_view = 1; album.album_viewed_day = 1; album.album_viewed_week = 1; album.album_viewed_month = 1; db.albums.Add(album); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.singer_id = new SelectList(db.singers, "singer_id", "singer_name", album.singer_id); return(View(album)); }
public ActionResult ChangeAlbumStatus(int Id, bool status) { try { if (status == true) { album xalbum = db.Albums.Find(Id); xalbum.status = true; db.Entry(xalbum).State = EntityState.Modified; db.SaveChanges(); var xuser = Udb.Users.Where(x => x.UserName == xalbum.username).FirstOrDefault(); string Email = xuser.Email; string NAme = xuser.Name; sendmail.AlbumAdded(NAme, Email, xalbum.AlbumName, xalbum.NoOFPics, xalbum.username); return(Content(xalbum.AlbumName + " is now Active")); } else { album xalbum = db.Albums.Find(Id); xalbum.status = false; db.Entry(xalbum).State = EntityState.Modified; db.SaveChanges(); return(Content(xalbum.AlbumName + " has been disactivated")); } } catch (Exception e) { return(Content("Please try again later")); } }
public ActionResult Albumthumbs() { album thisalbum = (album)Session["thisAlbum"]; var thumbsPics = db.Images.Where(z => z.AlbumId == thisalbum.Id).Select(x => x.themb).ToList(); return(PartialView("Albumthumbs", thumbsPics)); }
public ActionResult NewSongCreate(AlbumViewModel album) { //In case the user submits the album without adding a genre, don't assing a genrename. if (album.GenreID != 0) { album.GenreName = db.genres.Where(x => x.id == album.GenreID).First().genreName; } album al = album.FromModel(); if (ModelState.IsValid) { db.albums.Add(al); db.SaveChanges(); //If an artist isn't passed in from the new song page, then redirect to the new album in the song Index. if (album.importedArtist == true) { return(RedirectToAction("Create", "songs", new { ArtistID = album.ArtistID, AlbumID = al.id })); } else { return(RedirectToAction("AlbumIndex", "songs", new { AlbumID = al.id, ArtistID = album.ArtistID })); } } AlbumViewModel av = new AlbumViewModel(); av.ArtistNames = new SelectList(db.artists.OrderBy(x => x.artistName), "id", "artistName"); av.GenreNames = new SelectList(db.genres.OrderBy(x => x.genreName), "id", "genreName"); return(View(av)); }
public static string Description(upnpObject aObject) { string result = string.Empty; if (aObject is audioItem) { audioItem item = aObject as audioItem; result = item.Description; } else if (aObject is videoItem) { videoItem item = aObject as videoItem; result = item.Description; } else if (aObject is album) { album item = aObject as album; result = item.Description; } else if (aObject is playlistContainer) { playlistContainer item = aObject as playlistContainer; result = item.Description; } // always return a non-null string return(NonNullString(result)); }
public IActionResult Create([Bind("album_code,album_date,album_desc,album_name,created_by,id,rowversion,x_log,x_note,x_status")] album album) { album.album_type = "V"; //video album.x_status = "Y"; album.created_by = "Administrator"; _context.Add(album); _context.SaveChanges(); var pImages = _context.pic_image.Where(p => (p.ref_doc_code == album.album_code) && (p.x_status == "N")).ToList(); if (pImages != null) { foreach (var pImage in pImages) { pImage.x_status = "Y"; _context.Update(pImage); } _context.SaveChanges(); var uploads = Path.Combine(_env.WebRootPath, _configuration.GetSection("Paths").GetSection("images_upload").Value); uploads = Path.Combine(uploads, album.album_code); DirectoryInfo di = new DirectoryInfo(uploads); if (di.Exists) { var dest = Path.Combine(_env.WebRootPath, _configuration.GetSection("Paths").GetSection("images_album").Value); dest = Path.Combine(dest, album.album_code); Directory.Move(uploads, dest); } } return(RedirectToAction("Index")); }
internal List <string> AlbumPreview(string albumName) { album thisAlbum = db.Albums.Single(w => w.AlbumName == albumName); List <string> imgs = db.Images.Where(d => d.AlbumId == thisAlbum.Id).Select(f => f.themb).Take(4).ToList(); return(imgs); }
public ActionResult NewAllbum(string XuName) { album album = new album(); album.username = XuName; return(View(album)); }
public IActionResult ListAlbumVideo(string albumCode) { album album = _context.album.SingleOrDefault(m => m.album_code == albumCode); var abName = album.album_name; var abDesc = album.album_desc; var fiN = ""; var fiP = ""; List <photo> ph = new List <photo>(); var pImages = _context.pic_image.Where(p => (p.ref_doc_code == albumCode) && (p.x_status == "Y")).ToList(); if (pImages != null) { foreach (var pImage in pImages) { fiN = pImage.image_code; fiP = Path.Combine(albumCode, fiN); fiP = Path.Combine(_configuration.GetSection("Paths").GetSection("images_album").Value, fiP); if (pImage.image_desc == null) { pImage.image_desc = ""; } ph.Add(new photo { albumCode = albumCode, image_code = pImage.image_code, image_desc = pImage.image_desc, fileName = fiN, filePath = fiP, albumName = abName, albumDesc = abDesc }); } string pjson = JsonConvert.SerializeObject(ph); return(Json(pjson)); } else { return(Json("")); } }
public ActionResult InsertRelatedTables(int count) { List <MeasurementViewModel> results = new List <MeasurementViewModel>(); for (int i = 0; i < count; i++) { List <album> albums = new List <album>(); List <genre> genres = new List <genre>(); List <mediatype> mediaTypes = new List <mediatype>(); using (ChinookContext context = new ChinookContext()) { for (int j = 0; j < 100; j++) { album newAlbum = context.albums.Create(); newAlbum.ArtistId = 1; newAlbum.Title = "Inserted Album " + j.ToString(); albums.Add(newAlbum); genre newGenre = context.genres.Create(); newGenre.Name = "Inserted Genre " + j.ToString(); genres.Add(newGenre); mediatype newType = context.mediatypes.Create(); newType.Name = "Inserted Media Type"; mediaTypes.Add(newType); } ; List <track> tracks = new List <track>(); for (int j = 0; j < 100; j++) { track newTrack = context.tracks.Create(); newTrack.album = albums[j]; newTrack.Bytes = 123; newTrack.Composer = "Inseted Composer"; newTrack.genre = genres[j]; newTrack.mediatype = mediaTypes[j]; newTrack.Milliseconds = 123; newTrack.Name = "Inseted Track " + j.ToString(); newTrack.UnitPrice = 99; tracks.Add(newTrack); } measurement.Start(); context.tracks.AddRange(tracks); context.SaveChanges(); measurement.Stop(); results.Add(new MeasurementViewModel() { memory = measurement.memory, milliseconds = measurement.milliseconds }); } } return(View("MeasurementResults", results)); }
public void deletealbumn(album album) { if (album == null) { throw new ArgumentNullException(nameof(album)); } _context.albums.Remove(album); }
private void CreateAlbumCallback(album album, object state, FacebookException e) { fbService.Photos.UploadAsync(album.aid, "A photo to remember.", screenShotFormatter.GetScreenShot(), Enums.FileType.png, UploadCallback, null); }
public async Task <ActionResult> DeleteConfirmed(int id) { album album = await db.albums.FindAsync(id); db.albums.Remove(album); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,name")] album album) { if (ModelState.IsValid) { db.saveChange(); return(RedirectToAction("Index")); } return(View(album)); }
public ActionResult DeletImg(string imgName) { album thisalbum = (album)Session["thisAlbum"]; Img ximg = db.Images.Where(z => z.themb == imgName).FirstOrDefault(); thisalbum.NoOFPics = thisalbum.NoOFPics - 1; db.Entry(thisalbum).State = EntityState.Modified; db.Images.Remove(ximg); db.SaveChanges(); return(RedirectToAction("ManageAlbum", "Admin", new { Id = thisalbum.Id })); }
public async Task <IActionResult> Create([Bind("album_code,album_desc,album_name,created_by,album_date,rowversion")] album album) { album.x_status = "Y"; //album.album_code = DateTime.Now.ToString("yyMMddhhmmss"); album.created_by = "Administrator"; _context.Add(album); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); }
//public JsonResult CityList() //{ // try // { // var cityList = _cityService.GetCityList().Select(c => new { DisplayText = c.Name, Value = c.Id }); // return Json(new { Result = "OK", Options = cityList }); // } // catch (Exception ex) // { // return Json(new { Result = "ERROR", Message = ex.Message }); // } //} public JsonResult CreateAlbum(album album) { try { _albumService.CreateAlbum(album); return Json(new { Result = "OK", Record = album }); } catch (Exception ex) { return Json(new { Result = "ERROR", Message = ex.Message }); } }
public async Task <ActionResult> Edit([Bind(Include = "album_id,singer_id,album_name,album_createdate,album_image,album_view,album_viewed_day,album_viewed_week,album_viewed_month")] album album) { if (ModelState.IsValid) { db.Entry(album).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.singer_id = new SelectList(db.singers, "singer_id", "singer_name", album.singer_id); return(View(album)); }
public int InsertAlbum(album album) { string sql = "insert into album(creater_id,create_time,album_intro,photo)values(@creater_id,@create_time,@album_intro,@photo)"; SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@creater_id", album.creater_id), new SqlParameter("@create_time", album.create_time), new SqlParameter("@album_intro", album.album_intro), new SqlParameter("@photo", album.photo), }; return(DBHelper.GetExcuteNonQuery(sql, sp)); }
public bool addAlbum(album pAlbum) { bool error = false; try { error = this.dbService.addAlbum(pAlbum); } catch (Exception e) { error = true; } return error; }
public ActionResult editarAlbum(album data) { var repo = new user(Ent); if (repo.editarAlbum(data)) { return(RedirectToAction("Index", "Album", new { id = data.idArtista })); } else { return(RedirectToAction("editarAlbum", "Album", new { id = data.idArtista })); } }
public album getAlbumById(int pId) { album albumById = null; try { albumById = this.dbService.findAlbumById(pId); } catch (Exception e) { albumById = null; } return(albumById); }
public int UpdateAlbum(album album) { string sql = "update album set creater_id=@creater_id,create_time=@create_time,album_intro=@album_intro,photo_amount=@photo_amount,photo=@photo"; SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@creater_id", album.creater_id), new SqlParameter("@create_time", album.create_time), new SqlParameter("@album_intro", album.album_intro), new SqlParameter("@photo", album.photo), }; return(DBHelper.GetExcuteNonQuery(sql, sp)); }
public void addalbumn(Guid bandid, album album) { if (bandid == Guid.Empty) { throw new ArgumentNullException(nameof(bandid)); } if (album == null) { throw new ArgumentNullException(nameof(album)); } album.BandId = bandid; _context.albums.Add(album); }
public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } album album = await db.albums.FindAsync(id); if (album == null) { return(HttpNotFound()); } return(View(album)); }
public album SalvarThumbnail(Stream image, string root, album album) { if (image.Length > 0 && !string.IsNullOrEmpty(root)) { string srcPath = root + album.ThumbUrl; var fi = new FileInfo(srcPath); string filename = "AlbumThumb_" + album.Id.ToString(CultureInfo.InvariantCulture) + fi.Extension.ToString(CultureInfo.InvariantCulture); string destPath = root + AlbumPath + filename; album.ThumbUrl = AlbumUrl + filename; _image.CriarThumbnail(image, destPath); } return album; }
public ActionResult Excluir(int id, album collection) { try { // TODO: Add delete logic here _noticiaService.DeleteNoticia(collection.Id); return RedirectToAction("Index"); } catch { return View(); } }
public bool deleteAlbum(album pAlbum) { bool error = false; try { error = this.dbService.deleteAlbum(pAlbum); } catch (Exception e) { error = true; } return(error); }
private void getAlbumList() { HtmlElement root = wbPostToFanpage.Document.GetElementById("root"); HtmlElementCollection aColec = root.GetElementsByTagName("a"); foreach (HtmlElement a in aColec) { if (a.GetAttribute("href").Contains("/thoitrangella/albums/")) { string html = a.GetAttribute("href"); Regex reg = new Regex("/albums/([0-9]{6,30})"); MatchCollection mc = reg.Matches(html); album ab = new album(a.InnerText, mc[0].Groups[1].Value.ToString()); arrAlbumList.Add(ab); } } string url = ""; foreach (HtmlElement a in aColec) { if (a.InnerText != null) { if (a.GetAttribute("href").Contains("/photos/albums/") && a.InnerText.Contains("Xem thêm")) { url = a.GetAttribute("href"); break; } } } if (url != "") { wbPostToFanpage.Navigate(url); timeCheck.Start(); } else { if (_step == 1) { cbxAlbumList.DataSource = arrAlbumList; cbxAlbumList.DisplayMember = "name"; cbxAlbumList.ValueMember = "url"; MessageBox.Show("Get album list done"); } } }
public static List<album> getAlbumData(string url) { JObject response = JObject.Parse(performWebRequest(url)); List<album> albums = new List<album>(); Console.WriteLine("json:" + response); foreach (JToken token in response["data"]) { album curAlbum = new album(); curAlbum.id = token["id"].ToString(); JEnumerable<JToken> children = token.Children(); curAlbum.name = token.Value<string>("name") ?? ""; curAlbum.photos = new List<photo>(); albums.Add(curAlbum); } if (response["paging"].Value<string>("next") != null) albums.AddRange(getAlbumData(response["paging"]["next"].ToString())); return albums; }
public ActionResult Incluir(album collection) { try { // TODO: Add insert logic here var obj = collection; if (ModelState.IsValid) { obj.Usuario = new usuario { Id = 1 }; //album albumObj = _albumServico.Inclui(obj); var postedFile = Request.Files[0]; if (postedFile != null && postedFile.InputStream.Length > 0) { obj.ThumbUrl = postedFile.FileName; string imgPath = Server.MapPath("/Content/"); Stream foto = postedFile.InputStream; //_albumServico.SalvarThumbnail(foto, imgPath, albumObj); _albumService.SalvarThumbnail(foto, imgPath, obj); } _albumService.CreateAlbum(obj); return RedirectToAction("Index"); } else return View(collection); } catch { return View(); } }
// // GET: /Conteudo/album/Create //[Authorize(Roles="admin")] public ActionResult Incluir() { var obj = new album(); return View(obj); }
public List<cancion> getCancionesDeAlbum(album pAlbum) { List<cancion> canciones = null; try { cancion[] listaCanciones = dbService.findCancionesByAlbumId(pAlbum.idAlbum); if (listaCanciones != null) { canciones = new List<cancion>(listaCanciones); } } catch { canciones = null; } return canciones; }
public JsonResult UpdateAlbum(album album) { try { _albumService.UpdateAlbum(album); return Json(new { Result = "OK" }); } catch (Exception ex) { return Json(new { Result = "ERROR", Message = ex.Message }); } }
private void addAlbum(List<string> liste) { using (var musik = new pcindexEntities()) { List<string> list2 = (from p in musik.albums select p.Album1 ).ToList(); liste = listcompair(liste, list2); if (liste.Count >= 1) { foreach (var onpath in liste) { var entity = new album(); entity.Album1 = onpath; musik.albums.Add(entity); musik.SaveChanges(); } } } }
public album CreateAlbum(album _album) { /* Not used UnitOfWork attribute, because this method only calls one repository method and repoository can manage it's connection/transaction. */ _albumRepository.Insert(_album); return _albumRepository.Get(_album.Id); }
public void UpdateAlbum(album _album) { /* Not used UnitOfWork attribute, because this method only calls one repository method and repoository can manage it's connection/transaction. */ _albumRepository.Update(_album); }