// The id parameter name should match the DataKeyNames value set on the control
        public IQueryable<Category> DropDownListCategories_GetData()
        {
            PlaylistDbContext db = new PlaylistDbContext();
            var category = db.Categories;

            return category;
        }
        public IQueryable<Video> ListViewVideos_GetData([QueryString("id")]int? id)
        {
            PlaylistDbContext db = new PlaylistDbContext();
            var playlistVideos = db.Playlists.Find(id).Videos.AsQueryable();

            return playlistVideos;
        }
 // The id parameter name should match the DataKeyNames value set on the control
 public void ListViewVideos_DeleteItem(int Id)
 {
     PlaylistDbContext db = new PlaylistDbContext();
     var video = db.Videos.Find(Id);
     db.Videos.Remove(video);
     db.SaveChanges();
 }
 public Playlist FormViewPlaylist_GetItem([QueryString("id")]int? id)
 {
     if (id == null)
     {
         Response.Redirect("Home.aspx");
     }
     PlaylistDbContext db = new PlaylistDbContext();
     var playlist = db.Playlists.Find(id);
     return playlist;
 }
        public IQueryable<Playlist> ListViewPlaylists_GetData()
        {
            PlaylistDbContext db = new PlaylistDbContext();
            var playlist = db.Playlists
                            .Include(x => x.Category)
                            .Include(x => x.Author)
                            .Include(x => x.Ratings)
                            .Include(x => x.Videos);

            return playlist;
        }
Ejemplo n.º 6
0
        public void ListViewCategory_InsertItem()
        {
            var item = new Category();
            TryUpdateModel(item);

            if (ModelState.IsValid)
            {
                PlaylistDbContext db = new PlaylistDbContext();
                db.Categories.Add(item);
                db.SaveChanges();
            }
        }
 public void ListViewVideos_InsertItem([QueryString("id")]int id)
 {
     var item = new Video();
     item.PlaylistId = id;
     TryUpdateModel(item);
     if (ModelState.IsValid)
     {
         PlaylistDbContext db = new PlaylistDbContext();
         db.Videos.Add(item);
         db.SaveChanges();
     }
 }
Ejemplo n.º 8
0
        public IQueryable<Playlist> ListViewPopularPlaylists_GetData()
        {
            PlaylistDbContext db = new PlaylistDbContext();
            var popularPlaylists = db.Playlists
                .Include(x => x.Category)
                .Include(x => x.Ratings)
                .Include(x => x.Author)
                .Where(a => a.Ratings.Count == 0 || a.Ratings.Sum(l => l.Value) > 0)
                .OrderByDescending(a => a.Ratings.Sum(l => l.Value))
                .ThenBy(a => a.DateCreated).Take(10); ;

            return popularPlaylists;
        }
        public void ListViewPlaylists_InsertItem()
        {
            var item = new Playlist();
            item.DateCreated = DateTime.Now;
            item.AuthorId = User.Identity.GetUserId();

            TryUpdateModel(item);

            PlaylistDbContext db = new PlaylistDbContext();

            if (ModelState.IsValid)
            {
                db.Playlists.Add(item);
                db.SaveChanges();
            }
        }
Ejemplo n.º 10
0
 // The id parameter name should match the DataKeyNames value set on the control
 public void ListViewCategory_UpdateItem(int Id)
 {
     PlaylistDbContext db = new PlaylistDbContext();
     var category = db.Categories.Find(Id);
     if (category == null)
     {
         // The item wasn't found
         ModelState.AddModelError("", $"Product with id {category} was not found");
         return;
     }
     TryUpdateModel(category);
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
 public void ListViewVideos_UpdateItem(int Id)
 {
     PlaylistDbContext db = new PlaylistDbContext();
     var video = db.Videos.Find(Id);
     if (video == null)
     {
         // The item wasn't found
         ModelState.AddModelError("", $"Product with id {video} was not found");
         return;
     }
     TryUpdateModel(video);
     if (ModelState.IsValid)
     {
         db.Entry(video).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Ejemplo n.º 12
0
 // The return type can be changed to IEnumerable, however to support
 // paging and sorting, the following parameters must be added:
 //     int maximumRows
 //     int startRowIndex
 //     out int totalRowCount
 //     string sortByExpression
 public User ListViewProfile_GetData()
 {
     PlaylistDbContext db = new PlaylistDbContext();
     var userId = User.Identity.GetUserId();
     var user = db.Users.Find(userId);
     return user;
 }
Ejemplo n.º 13
0
 public IQueryable<Category> ListViewCategory_GetData()
 {
     PlaylistDbContext db = new PlaylistDbContext();
     var categories = db.Categories.Include(x => x.Playlists);
     return categories;
 }
Ejemplo n.º 14
0
 public PlaylistService(PlaylistDbContext context, IHostingEnvironment env)
 {
     _context = context;
     _env     = env;
 }