public NapsterController() { artistRepo = new ArtistRepo(); albumRepo = new AlbumRepo(); genreRepo = new GenreRepo(); trackRepo = new TrackRepo(); }
public ActionResult ViewAllAlbums() { var albumRepo = new AlbumRepo(); var albums = albumRepo.GetAll().Select(x => new Album(x)).ToList(); return(PartialView(albums)); }
public void AddAlbum_IfAlbumIdIsNotZeroShouldAddAlbum() { var options = new DbContextOptionsBuilder <AppDbContext>() .UseInMemoryDatabase(databaseName: random.Next().ToString()) .Options; using (var context = new AppDbContext(options)) { context.Albums.AddRange(_albums.ToList()); context.SaveChanges(); } using (var context = new AppDbContext(options)) { _albumRepo = new AlbumRepo(context); var album = new Album() { Id = 0 }; _albumRepo.AddAlbum(album); Assert.AreEqual(3, context.Albums.Count()); } }
// [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)] public ActionResult FetchData() { var albums = AlbumRepo.GetAlbums(); return(Json(albums, JsonRequestBehavior.AllowGet)); //return View(albums); }
public ActionResult UploadPhoto() { var photo = new GalleryPhotoViewModel(); var albums = AlbumRepo.GetAlbumsByUserId(UserRepo.GetUserId(User.Identity.Name)); albums.ForEach(x => photo.Albums.Add(new SelectListItem { Text = x.Name, Value = x.Id.ToString() })); return(PartialView(photo)); }
public ActionResult Index() { var albums = AlbumRepo.GetAlbums(); HttpCookie _userInfoCookies = Request.Cookies["UserInfo"]; if (_userInfoCookies != null) { string UserName = _userInfoCookies["UserName"].ToString(); } return(View(albums)); }
public ActionResult GetExcludedPhotoSelector(Guid userId, Guid albumId) { var albumrepo = new AlbumRepo(); var albumphotos = albumrepo.GetAlbumPhotos(albumId); var listOfPhotos = PhotoRepository.GetUserPhoto(userId).Select(x => new Photo(x)).ToList(); var excludedList = listOfPhotos.Where(p => albumphotos.All(x => x.PhotoID != p.PhotoID)).ToList(); return(PartialView("GetUserPhotosSelector", excludedList)); }
public ActionResult Index() { List <AlbumEntity> albumEntities = AlbumRepo.GetAll(); List <AlbumModel> albumModels = new List <AlbumModel>(); foreach (var albumEntity in albumEntities) { albumModels.Add(EntityModelMapper.EntityToModel(albumEntity)); } return(View(albumModels)); }
public ActionResult Index(AlbumModel album, string albumComment) { CommentModel commentModel = new CommentModel() { Comment = albumComment, DateCreated = DateTime.Now, Album = album, }; var commentEntity = EntityModelMapper.ModelToEntity(commentModel); CommentRepo.NewAlbumComment(album.AlbumModelId, commentEntity); return(View(AlbumRepo.GetAll())); }
public ActionResult Index(int?albumId, string albumName) { var albums = AlbumRepo.GetAlbums(); if (!string.IsNullOrEmpty(albumName)) { albums = albums.Where(a => a.Title.Contains(albumName)).ToList(); } if (albumId.HasValue) { albums = albums.Where(a => a.AlbumId == albumId).ToList(); } return(PartialView("_grid", albums)); }
public void DeleteAlbum_IfAlbumExistsShouldDeleteAlbum() { var options = new DbContextOptionsBuilder <AppDbContext>() .UseInMemoryDatabase(databaseName: random.Next().ToString()) .Options; using (var context = new AppDbContext(options)) { context.Albums.AddRange(_albums.ToList()); context.SaveChanges(); } using (var context = new AppDbContext(options)) { _albumRepo = new AlbumRepo(context); _albumRepo.DeleteAlbum(2); Assert.AreEqual(1, context.Albums.Count()); } }
public void Albums_ShouldReturnAllAlbums() { var options = new DbContextOptionsBuilder <AppDbContext>() .UseInMemoryDatabase(databaseName: random.Next().ToString()) .Options; using (var context = new AppDbContext(options)) { context.Albums.AddRange(_albums.ToList()); context.SaveChanges(); } using (var context = new AppDbContext(options)) { _albumRepo = new AlbumRepo(context); var result = _albumRepo.Albums; Assert.AreEqual(2, result.Count()); } }
public ActionResult Index(int?albumId, string albumName) { var albums = AlbumRepo.GetAlbums(); if (Request.Form["btnSubmit"] != null) { if (!string.IsNullOrEmpty(albumName)) { albums = albums.Where(a => a.Title.Contains(albumName)).ToList(); } if (albumId.HasValue) { albums = albums.Where(a => a.AlbumId == albumId).ToList(); } return(PartialView("_grid", albums)); } else if (Request.Form["btnDelete"] != null) { } return(PartialView("_grid", albums)); }
public void UpdateAlbum_IfAlbumExistsShouldUpdateAlbum() { var options = new DbContextOptionsBuilder <AppDbContext>() .UseInMemoryDatabase(databaseName: random.Next().ToString()) .Options; using (var context = new AppDbContext(options)) { context.Albums.AddRange(_albums.ToList()); context.SaveChanges(); } using (var context = new AppDbContext(options)) { _albumRepo = new AlbumRepo(context); _albumRepo.UpdateAlbum(new Album() { Id = 1, Description = "changed" }); Assert.AreEqual("changed", context.Albums.First(c => c.Id == 1).Description); } }
public ActionResult deleteData(string dataToBeDeleted) { var albums = AlbumRepo.GetAlbums(); //if (Request.Form["btnSubmit"] != null) //{ // if (!string.IsNullOrEmpty(albumName)) // albums = albums.Where(a => a.Title.Contains(albumName)).ToList(); // if (albumId.HasValue) // albums = albums.Where(a => a.AlbumId == albumId).ToList(); // return PartialView("_grid", albums); //} if (Request.Form["data"] != null) { String[] dids = Request.Form["data"].Split(new char[] { ',' }); } if (dataToBeDeleted != null) { String[] dids = dataToBeDeleted.Split(new char[] { ',' }); } return(PartialView("_grid", albums)); }
public ActionResult Create(AlbumModel albumModel) { try { int userId = albumModel.AlbumModelId; //TODO: userid and albumid the same? why? var albumEntity = EntityModelMapper.ModelToEntity(albumModel); //albumEntity.User = UserRepo.GetUser(userId); AlbumRepo.Add(albumEntity, userId);//adds new album to dbset(database) //create directory for new albums photos string newAlbumPath = Server.MapPath("~/UsersData/" + albumEntity.User.Username + "/" + albumEntity.Name); Directory.CreateDirectory(newAlbumPath); return(RedirectToAction("Index", "User")); } catch { return(View()); } }
public Albums() { repo = new AlbumRepo(); repoArtist = new ArtistRepo(); tracks = new Tracks(); }
public AlbumController() { AlbumRepository = new AlbumRepo(); }
public ActionResult Details(AlbumModel album) { var albumDetails = AlbumRepo.Get(album.AlbumModelId); return(View(albumDetails)); }
// // GET: /Home/ public ActionResult Index() { var albums = AlbumRepo.GetAlbums(); return(View(albums)); }