public async Task <int> CreateAsync(Artist artist)
        {
            var entity = new ArtistEntity
            {
                Name = artist.Name
            };

            _context.Artists.Add(entity);

            return(await _context.SaveChangesAsync());
        }
Exemple #2
0
        public async Task SeedAsync()
        {
            foreach (var a in _context.Albums)
            {
                _context.Albums.Remove(a);
            }
            foreach (var a in _context.Artists)
            {
                _context.Artists.Remove(a);
            }

            var morbid = new ArtistEntity {
                Name = "Morbid Angel"
            };
            var cannibal = new ArtistEntity {
                Name = "Cannibal Corpse"
            };
            var obituary = new ArtistEntity {
                Name = "Obituary"
            };

            _context.Artists.Add(morbid);
            _context.Artists.Add(cannibal);
            _context.Artists.Add(obituary);

            _context.Albums.AddRange(
                new AlbumEntity {
                Title = "Altars Of Madness", Artist = morbid, Year = 1989, Cover = await LoadBytesAsync("ms-appx:///Assets/Covers/AltarsOfMadness.jpg")
            },
                new AlbumEntity {
                Title = "Blessed Are The Sick", Artist = morbid, Year = 1991, Cover = await LoadBytesAsync("ms-appx:///Assets/Covers/BlessedAreTheSick.jpg")
            },
                new AlbumEntity {
                Title = "Covenant", Artist = morbid, Year = 1993, Cover = await LoadBytesAsync("ms-appx:///Assets/Covers/Covenant.jpg")
            },
                new AlbumEntity {
                Title = "Domination", Artist = morbid, Year = 1995, Cover = await LoadBytesAsync("ms-appx:///Assets/Covers/Domination.jpg")
            },
                new AlbumEntity {
                Title = "Formulas Fatal To The Flesh", Artist = morbid, Year = 1998, Cover = await LoadBytesAsync("ms-appx:///Assets/Covers/FormulasFatalToTheFlesh.jpg")
            },
                new AlbumEntity {
                Title = "Gateways To Annihilation", Artist = morbid, Year = 2000, Cover = await LoadBytesAsync("ms-appx:///Assets/Covers/GatewaysToAnnihilation.jpg")
            },
                new AlbumEntity {
                Title = "Heretic", Artist = morbid, Year = 2003, Cover = await LoadBytesAsync("ms-appx:///Assets/Covers/Heretic.jpg")
            },
                new AlbumEntity {
                Title = "Illud Divinum Insanus", Artist = morbid, Year = 2011, Cover = await LoadBytesAsync("ms-appx:///Assets/Covers/IlludDivinumInsanus.jpg")
            }
                );

            await _context.SaveChangesAsync();
        }