Exemplo n.º 1
0
 public async Task OnGetAsync()
 {
     if (!string.IsNullOrEmpty(searchString))
     {
         Artist = await _access.Get(searchString).ToListAsync();
     }
     else
     {
         Artist = await _access.Get("").ToListAsync();
     }
 }
Exemplo n.º 2
0
        public void Test()
        {
            ArtistDataAccess _access = new ArtistDataAccess(mockContext.Object);

            Artist artist = new Artist
            {
                ArtistID    = 999999,
                Name        = "Test",
                Rating      = 0.5f,
                Listens     = 3,
                Description = "descript",
                WordVec     = "1,2,3"
            };

            _access.Create(999999, artist);

            mockSet.Verify(m => m.Add(It.IsAny <Artist>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());

            var artist2 = _access.Get(999999).First();

            Assert.AreEqual(artist2.ArtistID, artist.ArtistID);
            Assert.AreEqual(artist2.Name, artist.Name);
            Assert.AreEqual(artist2.Rating, artist.Rating);
            Assert.AreEqual(artist2.Listens, artist.Listens);
            Assert.AreEqual(artist2.Description, artist.Description);
            Assert.AreEqual(artist2.WordVec, artist.WordVec);

            _access.Delete(999999);

            Assert.IsTrue(_access.Exists(999999));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Artist = await _access.Get(id.GetValueOrDefault()).FirstOrDefaultAsync();

            if (Artist == null)
            {
                return(NotFound());
            }
            return(Page());
        }