Example #1
0
        public void Execute(IServiceScope scope)
        {
            #region Migrations

            try
            {
                var list    = Genero.ListEmpty();
                var context = scope.ServiceProvider.GetService <ContextEf>();
                context.Database.Migrate();
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível realizar a migração dos dados iniciais. Erro:" + ex);
            }

            #endregion

            #region Spotify

            try
            {
                var spotifyService = scope.ServiceProvider.GetService <ISpotifyService>();
                spotifyService.InsertDiscs().GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível consumir a API do Spotify para inserir os discos por cada gênero. Erro:" + ex);
            }

            #endregion
        }
        private static List <Genero> BuildListGenero()
        {
            var list = Genero.ListEmpty();

            foreach (var item in Enumerators.GetEnumDescriptions(typeof(GeneroEnum)))
            {
                var newObj = Genero.Build(item.Key, item.Value);
                list.Add(newObj);
            }

            return(list);
        }