public void Delete(int id) { var nhac = context.NhacCaNhans.SingleOrDefault(x => x.IdNhacCaNhan == id); context.NhacCaNhans.Remove(nhac); context.SaveChanges(); }
public IActionResult ShowFavorites(int id, string title, string ArtistName, string album, string preview) { ViewBag.id = id; ViewBag.title = title; ViewBag.ArtistName = ArtistName; ViewBag.album = album; ViewBag.preview = preview; var favorites = new Favorites(); string newId = User.FindFirst(ClaimTypes.NameIdentifier).Value; favorites.UserId = newId; // favorites.FavoriteId = 15; favorites.ArtistName = ArtistName; favorites.SongTitle = title; favorites.SongId = id; favorites.AlbumCover = album; favorites.PreviewSong = preview; //favorites.Album = ; _context.Favorites.Add(favorites); _context.SaveChanges(); List <Favorites> favs = _context.Favorites.Where(x => x.UserId == newId).ToList(); favs.ForEach(x => x.UserId = User.FindFirst(ClaimTypes.Name).Value); return(View(favs)); }
public IHttpActionResult PutMusic(int id, Music music) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != music.Id) { return(BadRequest()); } db.Entry(music).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MusicExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Creates(string id, string name, string title, string code, string artists_names, string performer, string thumbnail, int duration, string lyricLink, int total, string url) { // Lấy danh sách CategoryID đưa vào List List <int> categoryIDList = categoryIDList = db.SongCategories.Select(c => c.ID).ToList(); int countID = categoryIDList.Count; try { var song = new Song(); song.IDZing = id; song.DisplayName = name; song.Title = title; song.Code = code; song.ArtistsNames = artists_names; song.Performer = performer; song.Thumbnail = thumbnail; song.Duration = duration; song.Lyric = lyricLink; song.ViewCount = total; song.URL = url; song.CategorySongID = categoryIDList[rand.Next(0, countID)]; db.Songs.Add(song); db.SaveChanges(); } catch (Exception ex) { return(Content("0")); } return(Content("1")); }
public void Add(AddPlaylistViewModel playlist) { Playlist newPlaylist = new Playlist { PlaylistName = playlist.NameOfPlaylist, PlaylistImage = playlist.UrlOfPlaylist }; if (newPlaylist.PlaylistName == null) { newPlaylist.PlaylistName = "Unknown name"; } if (newPlaylist.PlaylistImage == null) { newPlaylist.PlaylistImage = "https://i.stack.imgur.com/uRD9M.jpg"; } else if (newPlaylist.PlaylistImage.Contains(".png") || newPlaylist.PlaylistImage.Contains(".jpg") || newPlaylist.PlaylistImage.Contains(".jpeg")) { newPlaylist.PlaylistImage = playlist.UrlOfPlaylist; } else { newPlaylist.PlaylistImage = "https://i.stack.imgur.com/uRD9M.jpg"; } _context.Playlists.Add(newPlaylist); _context.SaveChanges(); return; }
public ActionResult Create([Bind(Include = "ID,Song,Artist,Album,Genre,ReleaseYear")] Music music) { if (ModelState.IsValid) { db.Musics.Add(music); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(music)); }
public int AddNew(Video obj) { var result = context.Videos.Add(obj); if (result != null) { context.SaveChanges(); return(result.IdVideo); } return(-1); }
public int AddNew(KhuVuc obj) { var result = context.KhuVucs.Add(obj); if (result != null) { context.SaveChanges(); return(result.IdKhuVuc); } return(-1); }
public int AddNew(TheLoai obj) { var result = context.TheLoais.Add(obj); if (result != null) { context.SaveChanges(); return(result.IdTheLoai); } return(-1); }
public ActionResult Create([Bind(Include = "Id,Name")] Genre genre) { if (ModelState.IsValid) { db.Genres.Add(genre); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(genre)); }
public int AddNew(TaiKhoan obj) { var result = context.TaiKhoans.Add(obj); if (result != null) { context.SaveChanges(); return(result.IdTaiKhoan); } return(-1); }
public ActionResult Create([Bind(Include = "ID,OwnerID,Artist,AlbumTitle,Year,Genre,OnLoan,LoanedToID,LoanedDate")] Music music) { if (ModelState.IsValid) { db.Music.Add(music); db.SaveChanges(); return(RedirectToAction("Index", "Collection")); } return(View(music)); }
public int AddNew(NguoiDung obj) { var result = context.NguoiDungs.Add(obj); if (result != null) { context.SaveChanges(); return(result.IdNguoiDung); } return(-1); }
public ActionResult Create([Bind(Include = "Id,Name,Artist,GenreId")] Song song) { if (ModelState.IsValid) { ViewBag.Genres = db.Genres.ToList(); db.Songs.Add(song); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(song)); }
public int Addalbum(Album obj) { obj.Hot = true; var result = context.Albums.Add(obj); if (result != null) { context.SaveChanges(); return(result.IdAlbum); } return(-1); }
public int AddNew(Tintuc obj) { obj.ThoiGian = DateTime.Now; var result = context.Tintucs.Add(obj); if (result != null) { context.SaveChanges(); return(result.IdTinTuc); } return(-1); }
public ActionResult Create(string name) { if (!string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name) && db.SongCategories.FirstOrDefault(c => c.DisplayName.ToUpper() == name.ToUpper().Trim()) == null) { var category = new SongCategory(); category.DisplayName = name; db.SongCategories.Add(category); db.SaveChanges(); } return(RedirectToAction("Index")); }
public int Delete(int id) { try { var song = db.Songs.FirstOrDefault(s => s.ID == id); db.Songs.Remove(song); db.SaveChanges(); return(1); } catch (Exception) { return(0); } }
public int AddNew(BaiHat obj) { obj.LuotNghe = 0; obj.LuotThich = 0; obj.LuotTai = 0; obj.Top100 = false; var result = context.BaiHats.Add(obj); if (result != null) { context.SaveChanges(); return(result.IdBaiHat); } return(-1); }
public IActionResult VerifyAccount(string id) { bool Status = false; // Confirm password does not match issue on save changes var v = dbContext.Users.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault(); if (v != null) { v.IsEmailVerified = true; dbContext.SaveChanges(); Status = true; return(StatusCode(StatusCodes.Status200OK)); } else { return(StatusCode(StatusCodes.Status500InternalServerError, "Invalid Request")); } }
public IActionResult SaveFavoriteAlbum(int id) { string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; AlbumT foundAlbum = new AlbumT(); try { foundAlbum = _musicDb.AlbumT.Where(x => x.Apiid == id).First(); } catch { foundAlbum.UserId = userId; foundAlbum.Apiid = id; _musicDb.AlbumT.Add(foundAlbum); _musicDb.SaveChanges(); return(RedirectToAction("DisplayAlbumFavorites")); } return(View("MusicIndex")); }
public void Save() { dbContext.SaveChanges(); }
public void Add(VideoYeuThich bh) { context.VideoYeuThiches.Add(bh); context.SaveChanges(); }
//Seed #region private void Seed() { using (var context = new MusicDBContext(options)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); context.PlayList.AddRange( new PlayList { Id = 1, UserId = 1, Name = "Sick EDM" }, new PlayList { Id = 2, UserId = 2, Name = "Country" } ); context.UploadMusic.AddRange( new UploadMusic { Id = 1, UserId = 1, MusicFilePath = "cool_song", Name = "Jumping Jacks", UploadDate = DateTime.Parse("2021-03-15 18:17:00"), Likes = 3409, Plays = 90845 }, new UploadMusic { Id = 2, UserId = 2, MusicFilePath = "crazy_mix", Name = "BBCRadio1Xtra Mix - Jack", UploadDate = DateTime.Parse("2021-03-16 18:18:00"), Likes = 8709, Plays = 3937829 } ); context.Comments.AddRange( new Comments { Id = 1, Comment = "wow this song is so sick what the heck!", CommentData = DateTime.Parse("2021-03-15 18:17:00"), UserId = 2, UploadMusicId = 1 }, new Comments { Id = 2, Comment = "what.. this song transition... amazing!", CommentData = DateTime.Parse("2021-03-15 18:17:00"), UserId = 1, UploadMusicId = 2 } ); context.MusicPlaylist.AddRange( new MusicPlaylist { Id = 1, PlayListId = 1, MusicId = 1, }, new MusicPlaylist { Id = 2, PlayListId = 1, MusicId = 2 }, new MusicPlaylist { Id = 3, PlayListId = 2, MusicId = 1 } ); context.SaveChanges(); } }
public void Add(NgheSiYeuThich bh) { context.NgheSiYeuThiches.Add(bh); context.SaveChanges(); }
public void Add(Song song) { context.Add(song); context.SaveChanges(); }
public int Complete() { return(_musicDBContext.SaveChanges()); }
// // GET: /Music/ public ViewResult Index() { db.SaveChanges(); return(View(db.Music.ToList())); }
public void Add(BaiHatYeuThich bh) { context.BaiHatYeuThiches.Add(bh); context.SaveChanges(); }
public void Add(BinhLuan bl) { bl.ThoiGian = DateTime.Now; context.BinhLuans.Add(bl); context.SaveChanges(); }