コード例 #1
0
 public NapsterController()
 {
     artistRepo = new ArtistRepo();
     albumRepo  = new AlbumRepo();
     genreRepo  = new GenreRepo();
     trackRepo  = new TrackRepo();
 }
コード例 #2
0
ファイル: GalleryController.cs プロジェクト: 7acc/MVC
        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
ファイル: PhotoController.cs プロジェクト: 7acc/MVC
        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
ファイル: AlbumController.cs プロジェクト: ivanprgomet-ip/mvc
        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
ファイル: AlbumController.cs プロジェクト: ivanprgomet-ip/mvc
        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
ファイル: AlbumController.cs プロジェクト: ivanprgomet-ip/mvc
        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
ファイル: AlbumController.cs プロジェクト: ivanprgomet-ip/mvc
        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));
        }