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")); }
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"); }
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" })); }
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); }
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()); } }
public ActionResult <Artist> NewArtist(Artist newArtist) { _artistService.AddArtist(newArtist); return(CreatedAtRoute("GetArtist", new { id = newArtist.Id }, newArtist)); }