private TrackDetail TrackDetailBuilder(Track track) { TrackDetail result = new TrackDetail(); result.Id = track.TrackId; result.AlbumId = track.AlbumId; result.TrackName = track.Name; result.Rate = track.Rate; Album album = db.Albums.Find(track.AlbumId); result.AlbumName = album.Name; result.AutorId = album.AutorId; Autor autor = db.Autors.Find(album.AutorId); result.AutorName = autor.Name; return result; }
private void EditItem(TrackViewModel model) { Track track = new Track { AlbumId = GetAlbumId(model.AlbumName), Name = model.Name, Rate = model.Rate, TrackId = model.Id }; db.Entry(track).State=EntityState.Modified; db.SaveChanges(); }
private TrackViewModel EditViewModelInitializer(Track track) { TrackViewModel result = new TrackViewModel { AlbumName = db.Albums.Find(track.AlbumId).Name, Id = track.TrackId, list = GetItemList(), Name = track.Name, Rate = track.Rate }; return result; }
private void AddItemToRepository(TrackViewModel model) { Track track = new Track { AlbumId = GetAlbumId(model.AlbumName), Name = model.Name, Rate = model.Rate }; db.Tracks.Add(track); db.SaveChanges(); }
private TrackDetail TrackDetailsViewModelConfig(Track track) { TrackDetail result = new TrackDetail { AlbumId = track.AlbumId, AutorName = db.Autors.Find(db.Albums.Find(track.AlbumId).AutorId).Name, AlbumName = db.Albums.Find(track.AlbumId).Name, AutorId = db.Albums.Find(track.AlbumId).AutorId, Id = track.TrackId, Rate = track.Rate, TrackName = track.Name }; return result; }