public ActionResult Create([FromForm] UserLibrary library) { try { _repository.Add(library); return(RedirectToAction(nameof(Index))); } catch { return(new BadRequestResult()); } }
static void Main(string[] args) { Console.WriteLine("Start!"); var genre = new Genre("Dubstep"); _genreRepository.Add(genre); Console.WriteLine("Genre created"); var country = new Country("Germany"); _countryRepository.Add(country); Console.WriteLine("Country created"); var userData = new CommonUserData("Egop", "Bird", "Tit", DateTime.Today); _commonUserDataRepository.Add(userData); Console.WriteLine("CommonUserData created"); var userLibrary = new UserLibrary(new List <Album>(), new List <Playlist>()); _userLibraryRepository.Add(userLibrary); Console.WriteLine("UserLibrary created"); var art = new Art("image.jpg"); _artRepository.Add(art); Console.WriteLine("Art created"); var playlist = new Playlist("test playlist", "test description", art, userLibrary, new List <TrackToPlaylist>()); _playlistRepository.Add(playlist); Console.WriteLine("Playlist created"); userLibrary.Playlists.Add(playlist); _userLibraryRepository.Update(userLibrary); Console.WriteLine("Playlist added to UserLibrary"); var distributorData = new DistributorData("test distributor", country, new List <Album>(), new List <ArtistToDistributor>()); _distributorDataRepository.Add(distributorData); Console.WriteLine("DistributorData created"); var album = new Album("test album", DateTime.Now, art, genre, distributorData, new List <Track>()); _albumRepository.Add(album); Console.WriteLine("Album created"); var track = new Track("Terror Drums", "test.mp3", 0, false, album, new List <TrackToPlaylist>()); track.Playlists.Add(new TrackToPlaylist(track, playlist)); _trackRepository.Add(track); Console.WriteLine("Track created"); //foreach (var genre in _genreRepository.GetAll()) //{ // Console.WriteLine(genre.Title); //} Console.ReadKey(); }
public void Post([FromBody] UserLibrary value) { _repository.Add(value); }