public ActionResult New(PlayListsViewModel model) { if (model.AddNewPlaylist.Private) { PrivatePlaylist p = new PrivatePlaylist() { Description = model.AddNewPlaylist.Description, PlaylistName = model.AddNewPlaylist.Name, Owner = userService.User.Id, UserName = userService.User.UserName }; playlistRepo.Add(p); } if (!model.AddNewPlaylist.Private) { Playlist p = new Playlist() { Description = model.AddNewPlaylist.Description, PlaylistName = model.AddNewPlaylist.Name, Owner = userService.User.Id }; playlistRepo.Add(p); } return(RedirectToAction("Index", "Playlists")); }
public void TryAddAnotherWithSameName_SeeWhatHappens() { var playlist = new Playlist { Name = "playlist" }; var another = new Playlist { Name = "playlist" }; repo.Add(playlist); void action() => repo.Add(another); Assert.Throws <LiteException>(action); }
public void Handle(PlaylistAdded evt) { if (_playlistRepository.Exists(evt.UserId)) { _playlistRepository.Update(evt.UserId); } else { _playlistRepository.Add(evt.UserId, evt.PlaylistId, evt.Name); } }
public ActionResult Create([FromForm] Playlist playlist) { try { _repository.Add(playlist); return(RedirectToAction(nameof(Index))); } catch { return(new BadRequestResult()); } }
public void Add(PlaylistModelView playlist, string Userid) { if (playlist == null) { throw new NullReferenceException(); } Playlist p = new Playlist() { Title = playlist.Title, UserId = Userid, Description = playlist.Description }; _playlistRepository.Add(p); _unitOfWork.Commit(); }
public async Task <ServiceResult> Add(PlaylistResultModel model) { var serviceResult = new ServiceResult(); var songsResult = model.Songs == null || model.Songs.Count == 0 ? new DatabaseManyResult <SongModel>() { Success = true, Entities = null } : await _songRepository.GetMany(model.Songs, 0, 50); if (!songsResult.Success) { serviceResult.Error.Code = ErrorStatusCode.BudRequest; serviceResult.Error.Description = songsResult.Message; return(serviceResult); } var modelObject = new PlaylistModel() { Id = model.Id, Name = model.Name, ArtId = model.ArtId, OwnerId = model.OwnerId, Songs = songsResult.Entities }; var result = await _playlistRepository.Add(modelObject); serviceResult.Success = result.Success; if (!result.Success) { serviceResult.Error.Code = ErrorStatusCode.BudRequest; serviceResult.Error.Description = result.Message; } return(serviceResult); }
public void Post([FromBody] Playlist value) { _repository.Add(value); }
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 string Add(Playlist playlist) { return(_playlistRepository.Add(playlist)); }
public void Add(Playlist user) { _playlistRepository.Add(user); }