Ejemplo n.º 1
0
		public PostsRepository(BlogContext context, ILogger<PostsRepository> logger)
		{
			_logger = logger;
			_context = context;
		}
Ejemplo n.º 2
0
		public BlogContextDataSeed(BlogContext context, UserManager<BlogUser> userManager)
		{
			_contex = context;
			_userManager = userManager;
		}
Ejemplo n.º 3
0
        protected override void Seed(Data.Context.BlogContext context)
        {
            //  This method will be called after migrating to the latest version.
            context.Categories.Add(new Category {
                Name = "ASP.NET MVC"
            });

            context.Categories.Add(new Category {
                Name = "Python Django"
            });

            context.Categories.Add(new Category {
                Name = "Java Play"
            });

            context.Categories.Add(new Category {
                Name = "NodeJS Express"
            });

            var author_1 = context.Authors.Add(new Author {
                Name = "Xavi Hernandez", Email = "*****@*****.**"
            });

            var author_2 = context.Authors.Add(new Author {
                Name = "Ivan Rakitic", Email = "*****@*****.**"
            });

            var author_3 = context.Authors.Add(new Author {
                Name = "Andrés Iniesta", Email = "*****@*****.**"
            });

            author_1.Books.Add(new Book {
                Title = "First book", Description = "Long long description that appears here"
            });
            author_1.Books.Add(new Book {
                Title = "Second book", Description = "Long long description that appears here"
            });
            author_1.Books.Add(new Book {
                Title = "Third book", Description = "Long long description that appears here"
            });
            author_1.Books.Add(new Book {
                Title = "Fourth book", Description = "Long long description that appears here"
            });

            author_2.Books.Add(new Book {
                Title = "Fifth book", Description = "Long long description that appears here"
            });
            author_2.Books.Add(new Book {
                Title = "Sixth book", Description = "Long long description that appears here"
            });
            author_2.Books.Add(new Book {
                Title = "Seventh book", Description = "Long long description that appears here"
            });

            author_3.Books.Add(new Book {
                Title = "Eighth book", Description = "Long long description that appears here"
            });
            author_3.Books.Add(new Book {
                Title = "Nineth book", Description = "Long long description that appears here"
            });

            context.SaveChanges();
        }
Ejemplo n.º 4
0
		public IEnumerable<string> Get()
		{
			BlogContext context = new BlogContext();
			var posts = context.Posts.ToList();
			return new string[] { "value1", "value2" };
		}