public ActionResult InsertSingleTables(int count) { List <MeasurementViewModel> results = new List <MeasurementViewModel>(); for (int i = 0; i < count; i++) { List <artist> artists = new List <artist>(); using (ChinookContext context = new ChinookContext()) { for (int j = 0; j < 100; j++) { artist newArtist = context.artists.Create(); newArtist.Name = "Inserted Artist " + j.ToString(); } measurement.Start(); context.artists.AddRange(artists); context.SaveChanges(); measurement.Stop(); results.Add(new MeasurementViewModel() { memory = measurement.memory, milliseconds = measurement.milliseconds }); } } return(View("MeasurementResults", results)); }
public void add_sample_data(ChinookDbContext db) { var digital_download = new media_type() { Name = "Digital Download" }; var rock_genre = new genre() { Name = "Rock" }; var new_artist = new artist() { Name = "Bob Sacamano" }; var new_album = new album() { Title = "My stuff 2018", Artist = new_artist }; var new_track = new track() { Name = "Bad Medicine", Album = new_album, Genre = rock_genre, MediaType = digital_download }; var new_playlist = new playlist() { PlaylistId = 0, Name = "Test playlist" }; var ref_playlist_track = new playlist_track() { playlist = new_playlist, track = new_track }; new_playlist.tracks.Add(ref_playlist_track); db.playlist_tracks.Add(ref_playlist_track); db.SaveChanges(); }
public async Task <IActionResult> submitMusic(artist data) { if (ModelState.IsValid) { try { dynamic dt; dt = data.artisID != 0 ? _db.Artists.FirstOrDefault(a => a.artisID == data.artisID) : new artist(); dt.artisName = data.artisName; dt.albumName = data.albumName; dt.imageURL = data.imageURL; dt.releaseDate = data.releaseDate; dt.price = data.price; dt.sampleURL = data.sampleURL; if (data.artisID != 0) { _db.Artists.Update(dt); } else { _db.Artists.Add(dt); } await _db.SaveChangesAsync(); return(Content("OK")); } catch (Exception ex) { return(Content(ex.Message.ToString())); } } return(View(data)); }
public ActionResult DeleteConfirmed(int id) { artist artist = db.artists.Find(id); db.artists.Remove(artist); db.SaveChanges(); return RedirectToAction("Index"); }
public async Task <IActionResult> AddSongToAlbum(int SongId, int AlbumId) { artist Artist = dataBaseContext.users.Where(u => u.UserName == HttpContext.User.Identity.Name).FirstOrDefaultAsync().Result.ArtistProfile; if (SongId != 0 && AlbumId != 0 && Artist != null) { playlist Album = await dataBaseContext.playlists.Where(p => p.Id == AlbumId).FirstOrDefaultAsync(); if (Artist.Albums.Contains(Album)) { song Song = await dataBaseContext.songs.Where(s => s.Id == SongId).FirstOrDefaultAsync(); Album.Songs.Add(Song); await dataBaseContext.SaveChangesAsync(); return(Redirect("/")); } else { return(Redirect("/")); } } else { return(Redirect("/")); } }
public HttpResponseMessage Put(int id, [FromUri] artist artist) { using (artistsDBEntities entities = new artistsDBEntities()) { try { var entity = entities.artists.FirstOrDefault(e => e.ID == id); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Artist with Id " + id.ToString() + " not found to update")); } else { entity.FirstName = artist.FirstName; entity.LastName = artist.LastName; entity.Genre = artist.Genre; entity.NumberOfAlbums = artist.NumberOfAlbums; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, entity)); } } catch (Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e)); } } }
public void DeleteElementRemovesExactlyThatElement() { artist art = this.ls.First(); this.ls.RemoveAt(this.ls.FindIndex(x => x.artist_id == 1)); this.artistLogic.Delete(art); Assert.That(this.artistLogic.GetAll(), Is.EqualTo(this.ls)); }
public ActionResult Edit([Bind(Include = "id,artistname")] artist artist) { if (ModelState.IsValid) { db.Entry(artist).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(artist); }
public async Task <IActionResult> Artist(string Name) { artist Artist = await dataBaseContext.artists.Where(a => a.BandName == Name).Include(a => a.Albums).Include(a => a.Subscribers).FirstOrDefaultAsync(); if (Artist != null) { return(View(Artist)); } return(Redirect("/404")); }
public ActionResult Create([Bind(Include = "id,artistname")] artist artist) { if (ModelState.IsValid) { db.artists.Add(artist); db.SaveChanges(); return RedirectToAction("Index"); } return View(artist); }
public ActionResult Edit(ArtistViewModel artist) { artist ar = artist.FromModel(); if (ModelState.IsValid) { db.Entry(ar).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(artist)); }
public ActionResult NewSongCreate(ArtistViewModel artist) { artist ar = artist.FromModel(); if (ModelState.IsValid) { db.artists.Add(ar); db.SaveChanges(); return(RedirectToAction("ArtistIndex", "songs", new { ArtistID = ar.id })); } return(View(artist)); }
// GET: artists/Delete/5 public ActionResult Delete(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } artist artist = db.artists.Find(id); if (artist == null) { return HttpNotFound(); } return View(artist); }
//Path: /api/Artist/CreateArtist public HttpResponseMessage CreateArtist(CreateArtist createArtistRequest) { // Trace Log File.AppendAllText(SuiteWrapper.traceLogPath, Environment.NewLine + Environment.NewLine); SuiteWrapper.WriteTraceLog("Called 'CreateArtist' with request :" + JsonConvert.SerializeObject(createArtistRequest)); CreateArtistResponse createArtistResponse = new CreateArtistResponse(); string outputMessage = string.Empty; if (!SuiteWrapper.ValidateRequest(createArtistRequest, out outputMessage)) { //Trace Log SuiteWrapper.WriteTraceLog("Exception while validating request for " + JsonConvert.SerializeObject(createArtistRequest) + " is : " + outputMessage); return(Request.CreateResponse(HttpStatusCode.NotAcceptable, outputMessage));; } try { using (PundolesEntities context = new PundolesEntities()) { artist artistObject = new artist(); artistObject.name = createArtistRequest.name; artistObject.description = createArtistRequest.description; artistObject.year_of_birth_c = createArtistRequest.year_of_birth_c; artistObject.year_of_death_c = createArtistRequest.year_of_death_c; artistObject.status = createArtistRequest.status; artistObject.created_date = DateTime.Now; artistObject.modified_date = DateTime.Now; artistObject.createdby_id = createArtistRequest.createdby_id; artistObject.modifiedby_id = createArtistRequest.createdby_id; context.artists.Add(artistObject); context.SaveChanges(); createArtistResponse.id = artistObject.id; createArtistResponse.status = "Success"; SuiteWrapper.WriteTraceLog("user is successfully created with response :" + JsonConvert.SerializeObject(createArtistResponse)); return(Request.CreateResponse(HttpStatusCode.OK, createArtistResponse)); } } catch (Exception ex) { createArtistResponse.id = null; createArtistResponse.status = ex.Message.ToString(); SuiteWrapper.WriteTraceLog("Exception while creating artist is : " + ex.Message.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, JsonConvert.SerializeObject(createArtistResponse))); } }
public ActionResult Create(ArtistViewModel artist) { artist ar = artist.FromModel(); if (ModelState.IsValid) { db.artists.Add(ar); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(artist)); }
public async Task <IActionResult> RegisterArtist(RegisterArtistViewModel model) { if (roleManager.FindByNameAsync("artist").Result == null) { await roleManager.CreateAsync(new IdentityRole("artist")); } if (ModelState.IsValid) { if (dataBaseContext.artists.Where(a => a.BandName == model.BandName).FirstOrDefault() == null) { user User = await dataBaseContext.users.Where(u => u.UserName == HttpContext.User.Identity.Name) .Include(u => u.ArtistProfile).FirstOrDefaultAsync(); if (User.ArtistProfile == null) { string FilePath = @"\static-files\"; var filestream1 = new FileStream(webHostEnvironment.WebRootPath + FilePath + model.BandName + "Logo.png", FileMode.Create); //webHostEnvironment.WebRootPath await model.Logo.CopyToAsync(filestream1); filestream1.Close(); artist Artist = new artist() { BandName = model.BandName, LogoPath = FilePath + model.BandName + "Logo.png" }; User.ArtistProfile = Artist; await dataBaseContext.artists.AddAsync(Artist); await userManager.AddToRoleAsync(User, "artist"); return(Redirect("/Home/Index")); } else { ModelState.AddModelError("BandName", "Только один исполнитель на аккаунт!"); return(View(model)); } } ModelState.AddModelError("BandName", "Это название уже занято!"); return(View(model)); } else { ModelState.AddModelError("BandName", "Что-то пошло не так..."); return(View(model)); } }
// GET: Artist/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } artist artist = db.artists.Find(id); if (artist == null) { return(HttpNotFound()); } ArtistViewModel ar = new ArtistViewModel(); ar.ToModel(artist); return(View(ar)); }
public void AddGeneratesId_Test() { var newArtist = new artist(); var conStr = ConfigurationManager.ConnectionStrings["chinookEntities"].ConnectionString; conStr = conStr.Replace("%SportFolder%", Environment.GetEnvironmentVariable("SportFolder")); newArtist.Name = "NEW_TEST_ARTIST"; var context = new chinookEntities(conStr); context.artists.Add(newArtist); context.SaveChanges(); Assert.IsTrue(newArtist.ArtistId != 0); context.artists.Remove(newArtist); context.SaveChanges(); }
public IActionResult addEdit(int id) { var model = new artist(); if (id != 0) { var data = _db.Artists.Find(id); model.artisID = data.artisID; model.artisName = data.artisName; model.albumName = data.albumName; model.imageURL = data.imageURL; model.releaseDate = data.releaseDate; model.price = data.price; model.sampleURL = data.sampleURL; } return(PartialView("addEdit", model)); }
public HttpResponseMessage Post([FromUri] artist artist) { try { using (artistsDBEntities entities = new artistsDBEntities()) { entities.artists.Add(artist); entities.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, artist); message.Headers.Location = new Uri(Request.RequestUri + artist.ID.ToString()); return(message); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
private upnpObject CreateUpnpObject(ISource aSource) { musicTrack item = new musicTrack(); resource resource = new resource(); resource.Uri = iDirectSound.SourceUri(aSource); resource.ProtocolInfo = "http-get:*:audio/x-wav:*"; resource.Bitrate = 44100; item.Res.Add(resource); item.Id = aSource.Id; item.Title = aSource.Name; item.Album.Add("SoundCard"); artist artist = new artist(); artist.Artist = "Various"; item.Artist.Add(artist); //item.AlbumArtUri = aSource.LogoUri; return(item); }
public ActionResult DeleteConfirmed(int id) { var songs = db.songs.Where(s => s.artist_id == id).ToList(); foreach (var s in songs) { db.songs.Remove(s); } var albums = db.albums.Where(s => s.artist_id == id).ToList(); foreach (var a in albums) { db.albums.Remove(a); } artist artist = db.artists.Find(id); db.artists.Remove(artist); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task FkInsertAsync() { var db = await GetForeignKeyEnabledConnectionAsync(); var artist = new artist() { artistid = 100, artistname = "Who Cares" }; await db.InsertAsync(artist); var track = new track() { trackid = 1000, trackname = "Song - What Song?", trackartist = 100 }; await db.InsertAsync(track); var trackInViolation = new track() { trackid = 1000, trackname = "Hey, I'll violate the FK", trackartist = 1 }; try { await db.InsertAsync(trackInViolation); } catch (Exception ex) { var exMessage = ex.Message; } // Do the cascaded delete - await db.DeleteAsync(artist); }
async void BuscarArtista() { try { _ListaAlbuns.Clear(); var WebAPI = DependencyService.Get <IWebAPIService>(); artist Artista = await WebAPI.GetLista(_TextoBusca); if (Artista != null) { ImagemArtista = "https://s2.vagalume.com/" + Artista.pic_medium; foreach (Item3 Album in Artista.albums.item) { _ListaAlbuns.Add(Album); } } ListaAlbumCountMaiorQueZero = _ListaAlbuns.Count > 0; } catch (Exception) { //throw; } }
private upnpObject UpnpObject(ITrack aTrack) { musicTrack track = new musicTrack(); artist artist = new artist(); artist.Artist = aTrack.Artist; artist.Role = "Performer"; track.Artist.Add(artist); resource resource = new resource(); Time time = new Time(aTrack.Duration); resource.Duration = time.ToString(); resource.Uri = aTrack.Uri; track.Res.Add(resource); track.Album.Add(aTrack.Album); track.AlbumArtUri.Add(aTrack.ArtworkUri); track.Title = aTrack.Title; return(track); }
/// <summary> /// the Action method that performs the actions on the tables /// </summary> /// <param name="inputType">takes a string type as a parameter to determine table</param> public void Action(string inputType) { int idNum; try { SongLogic songLogic = SongLogic.CreateRealLogic(); ArtistLogic artistLogic = ArtistLogic.CreateRealLogic(); ListenerLogic listenerLogic = ListenerLogic.CreateRealLogic(); PlayedOnConnLogic playedOnConnLogic = PlayedOnConnLogic.CreateRealLogic(); ListensToConnLogic listensToConnLogic = ListensToConnLogic.CreateRealLogic(); ServLogic serviceLogic = ServLogic.CreateRealLogic(); switch (inputType) { case "song": switch (this.Option) { case "1": song newSong = new song(); newSong.song_id = songLogic.GetAll().Count() + 1; Console.WriteLine("New Song Title: "); newSong.song_title = Console.ReadLine(); Console.WriteLine("New Song Album: "); newSong.song_album = Console.ReadLine(); Console.WriteLine("New Song Length (seconds): "); newSong.song_length = int.Parse(Console.ReadLine()); Console.WriteLine("Is the new song explicit? (true/false)"); newSong.song_explicit = bool.Parse(Console.ReadLine()); Console.WriteLine("Date of Release (DD/MM/YYYY): "); newSong.song_dateReleased = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Select an artist ID from below: \n "); foreach (artist item in artistLogic.GetAll()) { Console.WriteLine($"{item.artist_id} {item.artist_name} \n"); } newSong.song_artistId = int.Parse(Console.ReadLine()); songLogic.Insert(newSong); Console.WriteLine("Song has been added!"); break; case "2": foreach (var item in songLogic.GetAll()) { Console.WriteLine(item.ToString() + "\n"); } break; case "3": Console.WriteLine("Give an ID number"); idNum = int.Parse(Console.ReadLine()); Console.WriteLine(songLogic.GetById(idNum).ToString()); break; case "4": Console.WriteLine("What is the ID of the song you wish to update?"); song s = songLogic.GetById(int.Parse(Console.ReadLine())); Console.WriteLine("New Song Title: "); s.song_title = Console.ReadLine(); Console.WriteLine("New Song Album: "); s.song_album = Console.ReadLine(); Console.WriteLine("New Song Length (seconds): "); s.song_length = int.Parse(Console.ReadLine()); Console.WriteLine("Is the new song explicit? (true/false)"); s.song_explicit = bool.Parse(Console.ReadLine()); Console.WriteLine("Date of Release (DD/MM/YYYY): "); s.song_dateReleased = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Select an artist ID from below: \n "); foreach (artist item in artistLogic.GetAll()) { Console.WriteLine($"{item.artist_id} {item.artist_name} \n"); } s.song_artistId = int.Parse(Console.ReadLine()); songLogic.Update(s); Console.WriteLine("Song has been updated!"); break; case "5": Console.WriteLine("Give an ID number of Song to be Deleted"); idNum = int.Parse(Console.ReadLine()); songLogic.Delete(songLogic.GetById(idNum)); Console.WriteLine("Song has been deleted!"); break; } Console.ReadKey(); break; case "artist": switch (this.Option) { case "1": artist newArtist = new artist(); newArtist.artist_id = artistLogic.GetAll().Count() + 1; Console.WriteLine("New Artist Name: "); newArtist.artist_name = Console.ReadLine(); Console.WriteLine("New Artist Label: "); newArtist.artist_label = Console.ReadLine(); Console.WriteLine("New Artist Age: "); newArtist.artist_age = int.Parse(Console.ReadLine()); Console.WriteLine("New Artist Gender: "); newArtist.artist_gender = Console.ReadLine(); Console.WriteLine("New Artist Genre: "); newArtist.artist_genre = Console.ReadLine(); artistLogic.Insert(newArtist); Console.WriteLine("Artist has been added!"); break; case "2": foreach (var item in artistLogic.GetAll()) { Console.WriteLine(item.ToString() + "\n"); } break; case "3": Console.WriteLine("Give an ID number"); idNum = int.Parse(Console.ReadLine()); Console.WriteLine(artistLogic.GetById(idNum).ToString()); break; case "4": Console.WriteLine("What is the ID of the artist you wish to update?"); artist a = artistLogic.GetById(int.Parse(Console.ReadLine())); Console.WriteLine("New Artist Name: "); a.artist_name = Console.ReadLine(); Console.WriteLine("New Artist Label: "); a.artist_label = Console.ReadLine(); Console.WriteLine("New Artist Age: "); a.artist_age = int.Parse(Console.ReadLine()); Console.WriteLine("New Artist Gender: "); a.artist_gender = Console.ReadLine(); Console.WriteLine("New Artist Genre: "); a.artist_genre = Console.ReadLine(); artistLogic.Update(a); Console.WriteLine("Artist has been updated!"); break; case "5": Console.WriteLine("Give an ID number of Artist to be Deleted"); int deleteId = int.Parse(Console.ReadLine()); artistLogic.Delete(artistLogic.GetById(deleteId)); Console.WriteLine("Artist has been deleted!"); break; } Console.ReadKey(); break; case "listener": switch (this.Option) { case "1": listener newListener = new listener(); newListener.listener_id = listenerLogic.GetAll().Count() + 1; Console.WriteLine("New Listener Name: "); newListener.listener_name = Console.ReadLine(); Console.WriteLine("New Listener Country: "); newListener.listener_country = Console.ReadLine(); Console.WriteLine("New Listener Device Type: "); newListener.listener_deviceType = Console.ReadLine(); Console.WriteLine("New Listener Email: "); newListener.listener_email = Console.ReadLine(); Console.WriteLine("New Listener Gender: "); newListener.listener_gender = Console.ReadLine(); listenerLogic.Insert(newListener); Console.WriteLine("Listener has been added!"); break; case "2": foreach (var item in listenerLogic.GetAll()) { Console.WriteLine(item.ToString() + "\n"); } break; case "3": Console.WriteLine("Give an ID number"); idNum = int.Parse(Console.ReadLine()); Console.WriteLine(listenerLogic.GetById(idNum).ToString()); break; case "4": Console.WriteLine("What is the ID of the listener you wish to update?"); listener l = listenerLogic.GetById(int.Parse(Console.ReadLine())); Console.WriteLine("New Listener Name: "); l.listener_name = Console.ReadLine(); Console.WriteLine("New Listener Country: "); l.listener_country = Console.ReadLine(); Console.WriteLine("New Listener Device Type: "); l.listener_deviceType = Console.ReadLine(); Console.WriteLine("New Listener Email: "); l.listener_email = Console.ReadLine(); Console.WriteLine("New Listener Gender: "); l.listener_gender = Console.ReadLine(); listenerLogic.Update(l); Console.WriteLine("Listener has been updated!"); break; case "5": Console.WriteLine("Give an ID number of listener to be Deleted"); int deleteId = int.Parse(Console.ReadLine()); listenerLogic.Delete(listenerLogic.GetById(deleteId)); Console.WriteLine("Listener has been deleted!"); break; } Console.ReadKey(); break; case "playedon": switch (this.Option) { case "1": // GET ALL DOENST ORDER CORRECTLY conn_song_service newPlayedOnConn = new conn_song_service(); Console.WriteLine("Select a song ID from below: \n "); foreach (song item in songLogic.GetAll()) { Console.WriteLine($"{item.song_id} {item.song_title} \n"); } newPlayedOnConn.connOne_songId = int.Parse(Console.ReadLine()); Console.WriteLine("Select a service ID from below: \n "); foreach (serv item in serviceLogic.GetAll()) { Console.WriteLine($"{item.serv_id} {item.serv_name} \n"); } newPlayedOnConn.connOne_serviceId = int.Parse(Console.ReadLine()); playedOnConnLogic.Insert(newPlayedOnConn); Console.WriteLine("New played on connection has been added!"); break; case "2": foreach (var item in playedOnConnLogic.GetAll()) { Console.WriteLine(item.ToString() + "\n"); } break; case "3": Console.WriteLine("Give an ID number"); idNum = int.Parse(Console.ReadLine()); Console.WriteLine(playedOnConnLogic.GetById(idNum).ToString()); break; case "4": Console.WriteLine("What is the ID of the connection you wish to update?"); conn_song_service css = playedOnConnLogic.GetById(int.Parse(Console.ReadLine())); Console.WriteLine("Select a song ID from below: \n "); foreach (song item in songLogic.GetAll()) { Console.WriteLine($"{item.song_id} {item.song_title} \n"); } css.connOne_songId = int.Parse(Console.ReadLine()); Console.WriteLine("Select a service ID from below: \n "); foreach (serv item in serviceLogic.GetAll()) { Console.WriteLine($"{item.serv_id} {item.serv_name} \n"); } css.connOne_serviceId = int.Parse(Console.ReadLine()); playedOnConnLogic.Update(css); Console.WriteLine("Connection has been updated!"); break; case "5": Console.WriteLine("Give an ID number of PlayedOn Connection to be Deleted"); int deleteId = int.Parse(Console.ReadLine()); playedOnConnLogic.Delete(playedOnConnLogic.GetById(deleteId)); Console.WriteLine("Connection has been deleted!"); break; } Console.ReadKey(); break; case "listensto": switch (this.Option) { case "1": conn_listener_song newListensToConn = new conn_listener_song(); Console.WriteLine("Select a listener ID from below: \n "); foreach (listener item in listenerLogic.GetAll()) { Console.WriteLine($"{item.listener_id} {item.listener_name} \n"); } newListensToConn.connTwo_listenerId = int.Parse(Console.ReadLine()); Console.WriteLine("Select a song ID from below: \n "); foreach (song item in songLogic.GetAll()) { Console.WriteLine($"{item.song_id} {item.song_title} \n"); } newListensToConn.connTwo_songId = int.Parse(Console.ReadLine()); listensToConnLogic.Insert(newListensToConn); Console.WriteLine("New listens to connection has been added!"); break; case "2": foreach (var item in listensToConnLogic.GetAll()) { Console.WriteLine(item.ToString() + "\n"); } break; case "3": Console.WriteLine("Give an ID number"); idNum = int.Parse(Console.ReadLine()); Console.WriteLine(listensToConnLogic.GetById(idNum).ToString()); break; case "4": Console.WriteLine("What is the ID of the connection you wish to update?"); conn_listener_song cls = listensToConnLogic.GetById(int.Parse(Console.ReadLine())); Console.WriteLine("Select a listener ID from below: \n "); foreach (listener item in listenerLogic.GetAll()) { Console.WriteLine($"{item.listener_id} {item.listener_name} \n"); } cls.connTwo_listenerId = int.Parse(Console.ReadLine()); Console.WriteLine("Select a song ID from below: \n "); foreach (song item in songLogic.GetAll()) { Console.WriteLine($"{item.song_id} {item.song_title} \n"); } cls.connTwo_songId = int.Parse(Console.ReadLine()); listensToConnLogic.Update(cls); Console.WriteLine("Connection has been updated!"); break; case "5": Console.WriteLine("Give an ID number of connection to be Deleted"); int deleteId = int.Parse(Console.ReadLine()); listensToConnLogic.Delete(listensToConnLogic.GetById(deleteId)); Console.WriteLine("Connection has been deleted!"); break; } Console.ReadKey(); break; case "service": switch (this.Option) { case "1": serv newService = new serv(); newService.serv_id = serviceLogic.GetAll().Count() + 1; Console.WriteLine("New Service Name: "); newService.serv_name = Console.ReadLine(); Console.WriteLine("New Service Size: "); newService.serv_size = int.Parse(Console.ReadLine()); Console.WriteLine("New Service Website: "); newService.serv_website = Console.ReadLine(); Console.WriteLine("New Service Price: "); newService.serv_price = int.Parse(Console.ReadLine()); Console.WriteLine("New Service Country: "); newService.serv_country = Console.ReadLine(); serviceLogic.Insert(newService); Console.WriteLine("New Service has been added!"); break; case "2": foreach (var item in serviceLogic.GetAll()) { Console.WriteLine(item.ToString() + "\n"); } break; case "3": Console.WriteLine("Give an ID number"); idNum = int.Parse(Console.ReadLine()); Console.WriteLine(serviceLogic.GetById(idNum).ToString()); break; case "4": Console.WriteLine("What is the ID of the service you wish to update?"); serv ser = serviceLogic.GetById(int.Parse(Console.ReadLine())); Console.WriteLine("New Service Name: "); ser.serv_name = Console.ReadLine(); Console.WriteLine("New Service Size: "); ser.serv_size = int.Parse(Console.ReadLine()); Console.WriteLine("New Service Website: "); ser.serv_website = Console.ReadLine(); Console.WriteLine("New Service Price: "); ser.serv_price = int.Parse(Console.ReadLine()); Console.WriteLine("New Service Country: "); ser.serv_country = Console.ReadLine(); serviceLogic.Update(ser); Console.WriteLine("Service has been updated!"); break; case "5": Console.WriteLine("Give an ID number of Service to be Deleted"); int deleteId = int.Parse(Console.ReadLine()); serviceLogic.Delete(serviceLogic.GetById(deleteId)); Console.WriteLine("Service has been deleted!"); break; } Console.ReadKey(); break; } } catch { new ArgumentNullException(); } }
public void Process(NodeItem aNode) { LibraryItem libItem = aNode.LibraryItem; musicTrack track = new musicTrack(); track.Id = aNode.Id.ToString(); track.RefId = aNode.RefId.ToString(); track.ParentId = iParent.Id.ToString(); track.Restricted = true; track.WriteStatus = "PROTECTED"; if (libItem.Name != null) { track.Title = libItem.Name; } if (libItem.Album != null) { track.Album.Add(libItem.Album); } if (libItem.Artist != null) { artist artist = new artist(); artist.Artist = libItem.Artist; track.Artist.Add(artist); } if (libItem.Genre != null) { track.Genre.Add(libItem.Genre); } if (libItem.DiscCount != -1) { track.OriginalDiscCount = (int)libItem.DiscCount; } if (libItem.DiscNumber != -1) { track.OriginalDiscNumber = (int)libItem.DiscNumber; } if (libItem.TrackNumber != -1) { track.OriginalTrackNumber = (int)libItem.TrackNumber; } resource res = new resource(); if (libItem.BitRate != -1) { res.Bitrate = ((int)libItem.BitRate * 1000) / 8; } if (libItem.SampleRate != -1) { res.SampleFrequency = (int)libItem.SampleRate; } if (libItem.Size != -1) { res.Size = libItem.Size; } if (libItem.TotalTime != -1) { Upnp.Time totalTime = new Time(Convert.ToInt32(libItem.TotalTime / 1000)); res.Duration = totalTime.ToString(); } if (libItem.Kind.Contains("MPEG audio file")) { res.ProtocolInfo = "http-get:*:audio/mpeg:*"; } else if (libItem.Kind.Contains("WAV audio file")) { res.ProtocolInfo = "http-get:*:audio/x-wav:*"; } else if (libItem.Kind.Contains("AIFF audio file")) { res.ProtocolInfo = "http-get:*:audio/x-aiff:*"; } else if (libItem.Kind.Contains("AAC audio file")) { res.ProtocolInfo = "http-get:*:audio/x-m4a:*"; } else if (libItem.Kind.Contains("Apple Lossless audio file")) { res.ProtocolInfo = "http-get:*:audio/x-m4a:*"; } else { // if the file kind is unrecognised, set the protocol info so the // DS will decide - this means that KDT will add the track to the // DS playlist and then the DS can decide whether it wants to play it res.ProtocolInfo = "http-get:*:*:*"; } if (libItem.Location != null) { System.Uri uri = new System.Uri(libItem.Location); if (uri.Scheme == "file" && uri.Host == "localhost") { // handle paths that are "/Users/..." or "/C:\\Users\\..." i.e. mac or windows // strings passed to the VirtualFileSystem.Uri method must be unescaped. The unescaping // was initially implemented at the point where the Location element is read from // the XML file (the Location URI in the XML file is escaped). However, when this // unescaped string was passed to the Uri constructor, the uri.AbsolutePath returns // an **escaped** string, thus another unescape had to be performed here anyway. So, // no point in doing it twice - just do it here string path = System.Uri.UnescapeDataString(uri.AbsolutePath); if (path[2] == ':') { path = path.Substring(1); } try { res.Uri = iSupport.VirtualFileSystem.Uri(path); } catch (HttpServerException) { } } } if (res.ProtocolInfo != "" && res.Uri != "") { track.Res.Add(res); } if (libItem.AlbumArtId != null) { string filename = iLibrary.GetAlbumArtFilenameNoExt(libItem.AlbumArtId) + libItem.AlbumArtExt; try { string albumArtUri = iSupport.VirtualFileSystem.Uri(filename); track.AlbumArtUri.Add(albumArtUri); } catch (HttpServerException) { } } iMetadata = track; }
private void addArtist(List<string> liste) { // make artist list // remove duplets using (var musik = new pcindexEntities()) { List<string> list2 = (from p in musik.artists select p.Artist1 ).ToList(); liste = listcompair(liste, list2); if (liste.Count >= 1) { foreach (var onpath in liste) { var entity = new artist(); entity.Artist1 = onpath; musik.artists.Add(entity); musik.SaveChanges(); } } } }
static void Main(string[] args) { IArtRepo repo = new ArtRepo(); Console.WriteLine("Type database you wish to query"); string input = Console.ReadLine(); if (input == "artwork") { Console.WriteLine("Enter title of art or press a to see all the artwork"); input = Console.ReadLine(); if (input != "a") { //search for artwork by title artwork a = repo.GetArtWork(input); Console.WriteLine($"Artwork name, artist, date of creation, date acquired, type, price, customer phone, location = {a.unique_title}, {a.artist}, {a.date_of_creation},{a.date_acquired},{a.type_of_art},{a.price},{a.customerphone},{a.location}"); } else { List <artwork> ab = repo.GetArtWorks(); //print a list of all the artworks foreach (artwork a in ab) { Console.WriteLine($"Artwork name, artist, date of creation, date acquired, type, price, customer phone, location = {a.unique_title}, {a.artist}, {a.date_of_creation},{a.date_acquired},{a.type_of_art},{a.price},{a.customerphone},{a.location}"); } Console.WriteLine("Would you like to sort by style?"); input = Console.ReadLine(); if (input == "yes") { //sort artwork by style List <artwork> aws = repo.GetArtWorks(); var query = from aw in aws orderby aw.type_of_art ascending select aw; List <artwork> sorted = query.ToList(); foreach (artwork a in sorted) { Console.WriteLine($"Artwork name, artist, date of creation, date acquired, type, price, customer phone, location = {a.unique_title}, {a.artist}, {a.date_of_creation},{a.date_acquired},{a.type_of_art},{a.price},{a.customerphone},{a.location}"); } } } } else if (input == "artist") { Console.WriteLine("Enter name of artist or press a to see all the artists"); input = Console.ReadLine(); if (input != "a") { //search for artist based on name artist a = repo.GetArtist(input); Console.WriteLine($"name, address, phone, birthplace, age, style = {a.name}, {a.address}, {a.phone},{a.birth_place},{a.age},{a.style_of_art}"); } else { //print list of all artists List <artist> ab = repo.GetArtists(); foreach (artist a in ab) { Console.WriteLine($"name, address, phone, birthplace, age, style = {a.name}, {a.address}, {a.phone},{a.birth_place},{a.age},{a.style_of_art}"); } Console.WriteLine("Would you like to sort by style?"); input = Console.ReadLine(); if (input == "yes") { //sort artists by style List <artist> aws = repo.GetArtists(); var query = from aw in aws orderby aw.style_of_art ascending select aw; List <artist> sorted = query.ToList(); foreach (artist a in sorted) { Console.WriteLine($"name, address, phone, birthplace, age, style = {a.name}, {a.address}, {a.phone},{a.birth_place},{a.age},{a.style_of_art}"); } } } } else if (input == "customer") { Console.WriteLine("Enter phone# of customer or press a to see all the customers"); input = Console.ReadLine(); //search for customer by phone number if (input != "a") { customer a = repo.GetCustomer(input); Console.WriteLine($"Customer name, phone, preference = {a.name}, {a.phone}, {a.art_preferences}"); } else { //print a list of all customers List <customer> ab = repo.GetCustomers(); foreach (customer a in ab) { Console.WriteLine($"Customer name, phone, preference = {a.name}, {a.phone}, {a.art_preferences}"); } Console.WriteLine("Would you like to sort by preference?"); input = Console.ReadLine(); if (input == "yes") { //sort customers by art preference List <customer> aws = repo.GetCustomers(); var query = from aw in aws orderby aw.art_preferences ascending select aw; List <customer> sorted = query.ToList(); foreach (customer a in sorted) { Console.WriteLine($"Customer name, phone, preference = {a.name}, {a.phone}, {a.art_preferences}"); } } } } else if (input == "artshow") { Console.WriteLine("Enter art show date and time or press a to see all shows"); input = Console.ReadLine(); if (input != "a") { //find art show by date and time DateTime inputtedDateArt = DateTime.Parse(input); Console.WriteLine("Enter location of show"); input = Console.ReadLine(); art_show a = repo.getArtShow(inputtedDateArt, input); Console.WriteLine($"location, date and time, artist, contact name, contact phone = {a.location},{a.date_and_time},{a.artist},{a.contact_name}, {a.contact_phone}"); } else { //list all art shows List <art_show> ab = repo.getArtShows(); foreach (art_show a in ab) { Console.WriteLine($"location, date and time, artist, contact name, contact phone = {a.location},{a.date_and_time},{a.artist},{a.contact_name}, {a.contact_phone}"); } } } //See potential customers by show Console.WriteLine("Enter datetime of art show"); DateTime inputtedDate = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Enter location of show"); input = Console.ReadLine(); List <customer> potentialCustomers = repo.GetPotentialCustomersByShow(inputtedDate, input); foreach (customer c in potentialCustomers) { Console.WriteLine($"Customer name, phone number = {c.name} , {c.phone}"); } Console.ReadLine(); }
public void ToModel(artist a) { ArtistName = a.artistName; ArtistID = a.id; }
public static upnpObject Create(FileInfo aInfo, string aArtworkUri, string aResourceUri) { // check for playlist file if (aInfo.Extension == Playlist.kPlaylistExtension) { playlistContainer playlist = new playlistContainer(); resource resource = new resource(); playlist.Res.Add(resource); playlist.Id = aInfo.FullName; playlist.Title = aInfo.Name; playlist.WriteStatus = "PROTECTED"; playlist.Restricted = true; resource.Size = aInfo.Length; resource.Uri = aResourceUri; return(playlist); } // check for audio/video file try { if (IsTagLibSupported(aInfo)) { TagLib.File f = TagLib.File.Create(aInfo.FullName); if (f.Properties.MediaTypes == MediaTypes.Audio) { musicTrack track = new musicTrack(); resource resource = new resource(); track.Res.Add(resource); track.Id = aInfo.FullName; track.WriteStatus = "PROTECTED"; track.Restricted = true; if (!f.Tag.IsEmpty) { if (f.Tag.Title != null) { track.Title = f.Tag.Title; } else { track.Title = aInfo.Name; } if (f.Tag.Album != null) { track.Album.Add(f.Tag.Album); } foreach (string g in f.Tag.Genres) { track.Genre.Add(g); } track.OriginalTrackNumber = (int)f.Tag.Track; track.Date = f.Tag.Year.ToString(); foreach (string p in f.Tag.Performers) { artist performer = new artist(); performer.Artist = p; performer.Role = "Performer"; track.Artist.Add(performer); } foreach (string a in f.Tag.AlbumArtists) { artist artist = new artist(); artist.Artist = a; artist.Role = "AlbumArtist"; track.Artist.Add(artist); } foreach (string c in f.Tag.Composers) { artist composer = new artist(); composer.Artist = c; composer.Role = "Composer"; track.Artist.Add(composer); } if (f.Tag.Conductor != null) { artist conductor = new artist(); conductor.Artist = f.Tag.Conductor; conductor.Role = "Conductor"; track.Artist.Add(conductor); } } else { track.Title = aInfo.Name; } resource.Bitrate = (int)((f.Properties.AudioBitrate * 1000.0f) / 8.0f); resource.Duration = new Time((int)f.Properties.Duration.TotalSeconds).ToString(); resource.NrAudioChannels = f.Properties.AudioChannels; resource.SampleFrequency = f.Properties.AudioSampleRate; resource.Size = aInfo.Length; resource.Uri = aResourceUri; resource.ProtocolInfo = string.Format("http-get:*:{0}:*", f.MimeType.Replace("taglib", "audio")); resource.ProtocolInfo = resource.ProtocolInfo.Replace("flac", "x-flac"); resource.ProtocolInfo = resource.ProtocolInfo.Replace("aif:", "aiff:"); resource.ProtocolInfo = resource.ProtocolInfo.Replace("wma", "x-ms-wma"); resource.ProtocolInfo = resource.ProtocolInfo.Replace("asf", "x-ms-asf"); resource.ProtocolInfo = resource.ProtocolInfo.Replace("mp3", "mpeg"); resource.ProtocolInfo = resource.ProtocolInfo.Replace("mpeg3", "mpeg"); resource.ProtocolInfo = resource.ProtocolInfo.Replace("m4a", "x-m4a"); if (!string.IsNullOrEmpty(aArtworkUri)) { track.AlbumArtUri.Add(aArtworkUri); } return(track); } else if (f.Properties.MediaTypes == TagLib.MediaTypes.Video) { videoItem video = new videoItem(); resource resource = new resource(); video.Res.Add(resource); video.Id = aInfo.FullName; video.WriteStatus = "PROTECTED"; video.Restricted = true; if (!f.Tag.IsEmpty) { if (f.Tag.Title != null) { video.Title = f.Tag.Title; } else { video.Title = aInfo.Name; } foreach (string g in f.Tag.Genres) { video.Genre.Add(g); } foreach (string p in f.Tag.Performers) { actor performer = new actor(); performer.Actor = p; performer.Role = "Actor"; video.Actor.Add(performer); } } else { video.Title = aInfo.Name; } resource.Bitrate = (int)((f.Properties.AudioBitrate * 1000.0f) / 8.0f); resource.Duration = new Time((int)f.Properties.Duration.TotalSeconds).ToString(); resource.NrAudioChannels = f.Properties.AudioChannels; resource.SampleFrequency = f.Properties.AudioSampleRate; resource.Size = aInfo.Length; resource.Uri = aResourceUri; resource.ProtocolInfo = string.Format("http-get:*:{0}:*", f.MimeType.Replace("taglib", "video")); if (!string.IsNullOrEmpty(aArtworkUri)) { video.AlbumArtUri.Add(aArtworkUri); } return(video); } } } catch (TagLib.UnsupportedFormatException) { } catch (Exception e) { UserLog.WriteLine(aInfo.FullName + ": " + e.Message); } // check for image file string mimeType; if (IsImageFile(aInfo, out mimeType)) { photo photo = new photo(); resource resource = new resource(); photo.Res.Add(resource); photo.Id = aInfo.FullName; photo.Title = aInfo.Name; photo.WriteStatus = "PROTECTED"; photo.Restricted = true; resource.Size = aInfo.Length; resource.Uri = aResourceUri; resource.ProtocolInfo = string.Format("http-get:*:{0}:*", mimeType); if (!string.IsNullOrEmpty(aArtworkUri)) { photo.AlbumArtUri.Add(aArtworkUri); } return(photo); } // all other types { item item = new item(); resource resource = new resource(); item.Res.Add(resource); item.Id = aInfo.FullName; item.Title = aInfo.Name; item.WriteStatus = "PROTECTED"; item.Restricted = true; resource.Size = aInfo.Length; resource.Uri = aResourceUri; resource.ProtocolInfo = string.Format("http-get:*:application/octet-stream:*"); if (!string.IsNullOrEmpty(aArtworkUri)) { item.AlbumArtUri.Add(aArtworkUri); } return(item); } }