コード例 #1
0
 public ActionResult Create(PlayList playlist)
 {
     if (ModelState.IsValid) {
         playlistRepository.InsertOrUpdate(playlist);
         playlistRepository.Save();
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }
コード例 #2
0
 public void InsertOrUpdate(PlayList playlist)
 {
     if (playlist.PlayListId == default(int)) {
         // New entity
         context.PlayLists.Add(playlist);
     } else {
         // Existing entity
         context.Entry(playlist).State = EntityState.Modified;
     }
 }
コード例 #3
0
        public ActionResult AddToPlayList(int trackId, string returnUrl)
        {
            if (User.Identity.IsAuthenticated)
            {
                MusicRoomContext context = new MusicRoomContext();
                PlayListRepository playListRepository = new PlayListRepository();
                PlayList playList = new PlayList();
                foreach (var data in context.Tracks)
                {
                    if (data.TrackId == trackId)
                    {
                        playList.TrackPath = data.FileName;
                        playList.Author = data.Author;
                        playList.TrackName = data.TrackName;
                    }
                }
                playList.UserId = WebSecurity.CurrentUserId;

                playListRepository.InsertOrUpdate(playList);
                playListRepository.Save();

            }
            return Redirect(returnUrl);
        }