Ejemplo n.º 1
0
        public AddArtistModalWindowView()
        {
            InitializeComponent();
            AddArtistViewModel vm = new AddArtistViewModel();

            this.DataContext = vm;
            vm.CloseAction   = new Action(this.Close);
        }
        public IHttpActionResult AddArtistToInventory(AddArtistViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid Model State"));
            }

            var artist = _mapper.Map <Artist>(viewModel);

            _inventoryService.AddArtist(artist);

            return(Ok());
        }
Ejemplo n.º 3
0
        public void AddArtistToInventory_AddArtistViewModel_AddsArtistToDatabase()
        {
            var genre = new Genre {
                Id = Guid.NewGuid(), GenreId = Guid.NewGuid()
            };

            _context.Genres.Add(genre);
            _context.SaveChanges();

            var viewModel = new AddArtistViewModel {
                GenreIds = new List <Guid> {
                    genre.GenreId
                }
            };

            _inventoryController.AddArtistToInventory(viewModel);

            const int expected = 1;

            var artists = _context.Artists.ToList();

            Assert.AreEqual(expected, artists.Count);
        }