Пример #1
0
 public NapsterController()
 {
     artistRepo = new ArtistRepo();
     albumRepo  = new AlbumRepo();
     genreRepo  = new GenreRepo();
     trackRepo  = new TrackRepo();
 }
Пример #2
0
        public ActionResult ViewAllAlbums()
        {
            var albumRepo = new AlbumRepo();
            var albums    = albumRepo.GetAll().Select(x => new Album(x)).ToList();

            return(PartialView(albums));
        }
Пример #3
0
        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());
            }
        }
Пример #4
0
        // [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
        public ActionResult FetchData()
        {
            var albums = AlbumRepo.GetAlbums();

            return(Json(albums, JsonRequestBehavior.AllowGet));
            //return View(albums);
        }
Пример #5
0
        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));
        }
Пример #6
0
        public ActionResult Index()
        {
            var        albums           = AlbumRepo.GetAlbums();
            HttpCookie _userInfoCookies = Request.Cookies["UserInfo"];

            if (_userInfoCookies != null)
            {
                string UserName = _userInfoCookies["UserName"].ToString();
            }
            return(View(albums));
        }
Пример #7
0
        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));
        }
Пример #8
0
        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));
        }
Пример #9
0
        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()));
        }
Пример #10
0
        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));
        }
Пример #11
0
        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());
            }
        }
Пример #12
0
        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());
            }
        }
Пример #13
0
        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));
        }
Пример #14
0
        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);
            }
        }
Пример #15
0
        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));
        }
Пример #16
0
        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());
            }
        }
Пример #17
0
 public Albums()
 {
     repo = new AlbumRepo(); repoArtist = new ArtistRepo(); tracks = new Tracks();
 }
Пример #18
0
 public AlbumController()
 {
     AlbumRepository = new AlbumRepo();
 }
Пример #19
0
        public ActionResult Details(AlbumModel album)
        {
            var albumDetails = AlbumRepo.Get(album.AlbumModelId);

            return(View(albumDetails));
        }
Пример #20
0
        //
        // GET: /Home/

        public ActionResult Index()
        {
            var albums = AlbumRepo.GetAlbums();

            return(View(albums));
        }