Exemplo n.º 1
0
 public ActionResult EditViewclient(int viewclientId)
 {
     Viewclient viewclient = viewclientService.GetViewclientByID(viewclientId);
     if (viewclient == null)
     {
         return HttpNotFound();
     }
     ViewModel_EditPlaylistsInViewclient model = new ViewModel_EditPlaylistsInViewclient()
     {
         viewclientID = viewclient.ViewclientID,
         viewclientName = viewclient.Name
     };
     foreach (var connection in viewclientService.GetPlaylistConnections(viewclient.ViewclientID))
     {
         model.playlists.Add(new PlaylistView()
         {
             playlist = connection.Playlist,
             Playorder = connection.Playorder
         });
     }
     model.playlists.OrderBy(l => l.Playorder);
     return PartialView("~/Views/Viewclients/_EditViewclientPartial.cshtml", model);
 }
Exemplo n.º 2
0
 public ActionResult EditViewclient(int viewclientId, ViewModel_EditPlaylistsInViewclient model)
 {
     if(ModelState.IsValid)
     {
         viewclientService.UpdateViewclient(
             viewclientId, 
             new Viewclient() { Name = model.viewclientName }
             );
         foreach (var playlist in model.playlists)
         {
             ViewclientPlaylist connection = viewclientService.GetPlaylistConnection(viewclientId, playlist.playlist.PlaylistID);
             if(connection == null)
             {
                 viewclientService.ConnectPlaylist(viewclientId, playlist.playlist.PlaylistID);
             } else
             {
                 viewclientService.UpdatePlaylistConnection(connection,
                     new ViewclientPlaylist()
                     {
                         Playorder = connection.Playorder
                     });
             }
         }
         model.playlists.OrderBy(l => l.Playorder);
     }
     return PartialView("~/Views/Viewclients/_EditViewclientPartial.cshtml", model);
 }
Exemplo n.º 3
0
 public ActionResult DeletePlaylistFromViewclient(int playlistId, int viewclientId, ViewModel_EditPlaylistsInViewclient model)
 {
     viewclientService.DisconnectPlaylist(viewclientId, playlistId);
     foreach (ViewclientPlaylist connection in viewclientService.GetPlaylistConnections(viewclientId))
     {
         model.playlists.Add(new PlaylistView()
         {
             playlist = connection.Playlist,
             Playorder = connection.Playorder
         });
     }
     model.viewclientName = viewclientService.GetViewclientByID(viewclientId).Name;
     return PartialView("~/Views/Viewclients/_EditViewclientPartial.cshtml", model);
 }