Esempio n. 1
0
        public ActionResult AddArtist(AdminViewModel vm)
        {
            bool      isEmpty            = false;
            AddArtist artist             = vm.AddArtist;
            Type      getInfoRequestType = artist.GetType();

            PropertyInfo[] myProps = getInfoRequestType.GetProperties();
            foreach (var item in myProps)
            {
                if (item == null)
                {
                    isEmpty = true;
                }
            }
            if (!isEmpty)
            {
                Artist   a   = new Artist();
                string[] tmp = artist.Genres.Split(' ');
                foreach (string s in tmp)
                {
                    a.Genres.Add(s);
                }
                tmp = artist.Tags.Split(' ');
                foreach (string s in tmp)
                {
                    a.Tags.Add(s);
                }
                a.Picture    = artistRepo.SaveImage(artist.Picture, artist.Name);
                a.ArtistName = artist.Name;
                a.Biography  = artist.Biography;
                artistRepo.AddArtist(a);
                return(RedirectToAction("Index", "Admin"));
            }
            return(RedirectToAction("Index", "Admin"));
        }
Esempio n. 2
0
        public void Setup()
        {
            artistRepositoryMock = new Mock <IEfRepository <Artist> >();
            unitOfWorkMock       = new Mock <IUnitOfWork>();
            dateTimeMock         = new Mock <IDateTimeProvider>();
            albumServiceMock     = new Mock <IAlbumService>();

            service = new ArtistService(artistRepositoryMock.Object, unitOfWorkMock.Object, dateTimeMock.Object, albumServiceMock.Object);

            service.AddArtist("ivan", "bulgaria", "bio");
        }
Esempio n. 3
0
        public ActionResult AddArtist(FormCollection frm)
        {
            ArtistDTO artist = new ArtistDTO();

            UpdateModel(artist);
            ArtistService artistService = new ArtistService();

            //Get Artists list
            artistService.AddArtist(artist);

            return(RedirectToAction("Artists", "Artist", new { area = "Admin" }));
        }
Esempio n. 4
0
        public void AddArtistTest()
        {
            IArtistService artistService = new ArtistService(_context, _mapper);

            var artist = new CreateArtistRequest
            {
                Name   = "The Doors",
                Review = "An American rock band formed in Los Angeles in 1965"
            };

            var result = artistService.AddArtist(artist, CancellationToken.None);

            result.ShouldBeOfType <int>();
            result.ShouldBe(3);
        }
Esempio n. 5
0
        public void AddArtistTest()
        {
            Artist artist = new Artist()
            {
                id           = 3,
                name         = "Justin Bieber",
                description  = "No description needed",
                startingDate = new DateTime(2007, 1, 1),
                endingDate   = null
            };

            ArtistService service     = new ArtistService(_artistRepository);
            bool          returnValue = service.AddArtist(artist);

            Assert.IsTrue(returnValue);
        }
        public async Task <ActionResult> Create(Artist artist)
        {
            var auth = GetCookies();

            artist.Id = auth["uid"];
            try
            {
                var artistRequest = new ArtistRequest()
                {
                    Auth   = auth,
                    Artist = artist
                };
                await _artistService.AddArtist(artistRequest);

                return(RedirectToAction("Details"));
            }
            catch
            {
                //TODO send in error back to view
                return(View());
            }
        }
Esempio n. 7
0
 public ActionResult <Artist> NewArtist(Artist newArtist)
 {
     _artistService.AddArtist(newArtist);
     return(CreatedAtRoute("GetArtist", new { id = newArtist.Id }, newArtist));
 }