public void OnGet() { Heading1 = "Chinook Music Company"; Chinook db = new Chinook(); //Albums = db.Albums.Select( a => a.AlbumId.ToString() + ". " + a.Title + " " + a.Artist.ArtistId); //Tracks = db.Tracks.Select( b => b.TrackId.ToString() + "." + b.Name + " " + b.Composer); }
// PUT api/tracks/5 public HttpResponseMessage Put(int id, [FromBody] Tracks tracks) { tracks.TrackId = id; var value = Chinook.UpsertTrack(tracks); return(Request.CreateResponse(HttpStatusCode.OK, tracks)); }
public AlbumIndexViewModel(Chinook.Repository.IMusicRepository musicRepository, int page, int pageSize = 5) { PageSize = pageSize; var albums = musicRepository.GetAlbums(); int totalRows = albums.Count(); int totalPages = (int)Math.Ceiling((double)totalRows / pageSize); int currentPage = page; if (currentPage < 1) currentPage = 1; if (currentPage > totalPages) currentPage = totalPages; int startRow = (currentPage - 1) * pageSize; CurrentPage = currentPage; TotalPages = totalPages; NextPage = currentPage < totalPages ? currentPage + 1 : (int?)null; PreviousPage = currentPage > 1 ? currentPage - 1 : (int?)null; StartingRow = startRow + 1; Albums = from a in albums.OrderBy(x => x.AlbumID).Skip(startRow).Take(pageSize) select new AlbumViewModel { AlbumID = a.AlbumID, Title = a.Title, Artist = musicRepository.GetArtists().Where(x => x.ID == a.ArtistID).Select(x => x.Name).FirstOrDefault(), }; }
public HttpResponseMessage Get(string artistId) { int id = Convert.ToInt32(artistId); var value = Chinook.AlbumsByArtist(id); return(Request.CreateResponse(HttpStatusCode.OK, value)); }
// DELETE api/tracks public HttpResponseMessage Delete([FromBody] int[] value) { foreach (int id in value) { Chinook.DeleteTrack(id); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public void Non_existant_placeholder() { var c = new Chinook(); var p = new PlaceholderParser(); var d = p.Parse(c, "Hello, [Does.Not.Exist]!"); Assert.AreEqual(0, d.Count); }
public void OnGet() { Heading1 = "Albums"; // Albums = new[] {} Chinook db = new Chinook(); Albums = db.Albums.Select(a => a.AlbumId.ToString() + ". " + a.ArtistId + ". " + a.Title); }
public void No_placeholders() { var c = new Chinook(); var p = new PlaceholderParser(); var d = p.Parse(c, "Hello, world!"); Assert.AreEqual(0, d.Count); }
public void Invalid_path_placeholder() { var c = new Chinook(); var p = new PlaceholderParser(); var d = p.Parse(c, "Hello, [Track.Album.Name]!"); Assert.AreEqual(0, d.Count); }
public void One_placeholder() { var c = new Chinook(); var p = new PlaceholderParser(); var d = p.Parse(c, "Hello, [Track.Name]!"); Assert.AreEqual(1, d.Count); Assert.IsTrue(d.ContainsKey("[Track.Name]")); Assert.AreEqual(new FieldPath(c.Track["Name"]), d["[Track.Name]"]); }
public void Depth2_placeholder() { var c = new Chinook(); var p = new PlaceholderParser(); var d = p.Parse(c, "Hello, [Track.AlbumId.Title]!"); Assert.AreEqual(1, d.Count); Assert.IsTrue(d.ContainsKey("[Track.AlbumId.Title]")); Assert.AreEqual(new FieldPath(c.Track["AlbumId"], c.Album["Title"]), d["[Track.AlbumId.Title]"]); }
public void Single_field_path() { var config = new Chinook(); var factory = new Factory(); var adapter = new FieldPathComboAdapter(factory); var path = new FieldPath(config["Track"]["Name"]); var fields = factory.GetFields(path[0].Subject); adapter.SelectedPath = path; Assert.AreEqual(1, adapter.Items.Count); Assert.AreEqual(fields.Count, adapter.Items[0].Fields.Count); Assert.Contains(path[0], adapter.Items[0].Fields); }
public void Double_field_path() { var config = new Chinook(); var factory = new Factory(); var adapter = new FieldPathComboAdapter(factory); var path = new FieldPath(config["Track"]["AlbumId"], config["Album"]["Title"]); var fields1 = factory.GetFields(path[0].Subject); var fields2 = factory.GetFields(path[1].Subject); adapter.SelectedPath = path; Assert.AreEqual(2, adapter.Items.Count); Assert.AreEqual(fields1.Count, adapter.Items[0].Fields.Count); Assert.AreEqual(fields2.Count, adapter.Items[1].Fields.Count); Assert.Contains(path[0], adapter.Items[0].Fields); Assert.Contains(path[1], adapter.Items[1].Fields); }
public AlbumSearchViewModel(string phrase, Chinook.Repository.IMusicRepository musicRepository) { phrase = phrase.ToLower(); var artists = musicRepository.GetArtists().ToArray(); var artistQuery = from x in artists select x; if (!String.IsNullOrWhiteSpace(phrase)) { artistQuery = from x in artistQuery where x.Name.ToLower().Contains(phrase) select x; } var artistIDs = (from x in artistQuery select x.ID).ToArray(); var query = from x in musicRepository.GetAlbums() where artistIDs.Contains(x.ArtistID) select x; if (!String.IsNullOrWhiteSpace(phrase)) { var query2 = from x in musicRepository.GetAlbums() where x.Title.ToLower().Contains(phrase) select x; query = query.Union(query2); } var albums = query.Distinct(); Albums = from a in albums select new AlbumViewModel { AlbumID = a.AlbumID, Title = a.Title, Artist = artists.Where(x => x.ID == a.ArtistID).Select(x => x.Name).FirstOrDefault(), }; }
public void Incomplete_field_path() { var config = new Chinook(); var factory = new Factory(); var adapter = new FieldPathComboAdapter(factory); var path = new FieldPath(config["Track"]["AlbumId"], config["Album"]["ArtistId"]); var fields1 = factory.GetFields(path[0].Subject); var fields2 = factory.GetFields(path[1].Subject); var fields3 = factory.GetFields(config["Artist"]); // this should be added by SelectedPath adapter.SelectedPath = path; Assert.AreEqual(3, adapter.Items.Count); Assert.AreEqual(fields1.Count, adapter.Items[0].Fields.Count); Assert.AreEqual(fields2.Count, adapter.Items[1].Fields.Count); Assert.AreEqual(fields3.Count, adapter.Items[2].Fields.Count); Assert.Contains(path[0], adapter.Items[0].Fields); Assert.Contains(path[1], adapter.Items[1].Fields); Assert.Contains(path[2], adapter.Items[2].Fields); }
static void Main(string[] args) { Guppy guppy = new Guppy(); Console.WriteLine("============GUPPY============"); Console.WriteLine(guppy.EatsFood()); Console.WriteLine($"Guppies are HUGE fish {guppy.PetFish}"); Console.WriteLine($"Guppies are cold blooded Animals {guppy.ColdBlooded}"); Owl owl = new Owl(); Console.WriteLine("============OWL============"); Console.WriteLine($"Owls have feathers {owl.Feathers}"); Console.WriteLine($"Owls can fly {owl.CanFly()}"); Console.WriteLine($"Owls have wings {owl.Wings}"); Sockeye sockeye = new Sockeye(); Console.WriteLine("============SOCKEYE============"); Console.WriteLine(sockeye.EatsFood()); Console.WriteLine($"Sockeyes lay eggs {sockeye.LaysEggs()}"); Console.WriteLine($"Sockeye are { sockeye.Scaley} "); Chinook chinook = new Chinook(); Console.WriteLine("============CHINOOK============"); Console.WriteLine(chinook.EatsFood()); Console.WriteLine($"Chinook fish can ingest food {chinook.Heterotrophy}"); Console.WriteLine($"Chinook fish have a tail { chinook.HasTail }"); AfricanPenguin africanpenguin = new AfricanPenguin(); Console.WriteLine("============AFRICAN PENGUIN============"); Console.WriteLine($"African Penguin has feathers {africanpenguin.Feathers}"); Console.WriteLine($"African Penguins can't fly {africanpenguin.CanFly()}"); Console.WriteLine($"African Penguin have Wings { africanpenguin.Wings}"); }
public void ChinnokSwim() { Chinook chinook = new Chinook(); Assert.True(chinook.Swims()); }
public void Setup() { _db = new Chinook(); }
// GET api/tracks public HttpResponseMessage Get() { var value = Chinook.Tracks(0); return(Request.CreateResponse(HttpStatusCode.OK, value)); }
// POST api/tracks public HttpResponseMessage Post([FromBody] Tracks tracks) { var value = Chinook.UpsertTrack(tracks); return(Request.CreateResponse(HttpStatusCode.OK, tracks)); }
public HttpResponseMessage Get(int id) { var value = Chinook.Albums(id); return(Request.CreateResponse(HttpStatusCode.OK, value)); }
public ChinookController(IConfiguration config) { _chinook = new Chinook(config); }
public AlbumEditViewModel(Chinook.DomainModel.Album album, Chinook.Repository.IMusicRepository musicRepository) { Album = new AlbumInputModel(album); Artists = new SelectList(musicRepository.GetArtists(), "ID", "Name", album.ArtistID); }
// DELETE api/tracks/5 public HttpResponseMessage Delete(int id) { Chinook.DeleteTrack(id); return(Request.CreateResponse(HttpStatusCode.OK)); }
public DeleteModel(Chinook context) { _context = context; }
public AlbumsModel(Chinook injectedContext) { db = injectedContext; }
public void ChinnokIsAFish() { Chinook chinook = new Chinook(); Assert.True(chinook is Fish); }