Assignment6.Controllers.Manager.PlaylistGetByIdWithDetails C# (CSharp) Method

PlaylistGetByIdWithDetails() public method

public PlaylistGetByIdWithDetails ( int id ) : PlaylistWithDetails
id int
return PlaylistWithDetails
        public PlaylistWithDetails PlaylistGetByIdWithDetails(int id)
        {
            // Playlist get one

            // Attempt to fetch the object
            var o = ds.Playlists
                .Include("Tracks")
                .SingleOrDefault(p => p.PlaylistId == id);

            return (o == null) ? null : Mapper.Map<PlaylistWithDetails>(o);
        }

Usage Example

        // GET: Playlists/Details/5
        public ActionResult Details(int?id)
        {
            // Study the Details view

            // Attempt to get the matching object
            var o = m.PlaylistGetByIdWithDetails(id.GetValueOrDefault());

            if (o == null)
            {
                return(HttpNotFound());
            }
            else
            {
                // Pass the object to the view
                return(View(o));
            }
        }