示例#1
0
 public bool Save()
 {
     return(_context.SaveChanges() >= 0);
 }
        public static void EnsureSeedDataForContext(this LandingPageContext context)
        {
            if (context.LandingPageSummaries.Any())
            {
                return;
            }

            var landingPageSummaries = new List <LandingPageSummary>()
            {
                new LandingPageSummary()
                {
                    Name               = "Google",
                    Url                = "mail.google.com",
                    Description        = "My google account.",
                    LandingPageDetails = new List <LandingPageDetail>()
                    {
                        new LandingPageDetail()
                        {
                            UserId      = "*****@*****.**",
                            Password    = "******",
                            Description = "My first google account"
                        },
                        new LandingPageDetail()
                        {
                            UserId      = "*****@*****.**",
                            Password    = "******",
                            Description = "My second google account"
                        },
                    }
                },
                new LandingPageSummary()
                {
                    Name               = "Apple",
                    Url                = "mail.apple.com",
                    Description        = "My apple account.",
                    LandingPageDetails = new List <LandingPageDetail>()
                    {
                        new LandingPageDetail()
                        {
                            UserId      = "*****@*****.**",
                            Password    = "******",
                            Description = "My first apple account"
                        },
                        new LandingPageDetail()
                        {
                            UserId      = "*****@*****.**",
                            Password    = "******",
                            Description = "My second apple account"
                        },
                    }
                },
                new LandingPageSummary()
                {
                    Name               = "Bank Of America",
                    Url                = "mailbofa.google.com",
                    Description        = "My Bofa account.",
                    LandingPageDetails = new List <LandingPageDetail>()
                    {
                        new LandingPageDetail()
                        {
                            UserId      = "*****@*****.**",
                            Password    = "******",
                            Description = "My first Bofa account"
                        },
                        new LandingPageDetail()
                        {
                            UserId      = "*****@*****.**",
                            Password    = "******",
                            Description = "My second Bofa account"
                        },
                    }
                }
            };

            context.LandingPageSummaries.AddRange(landingPageSummaries);
            context.SaveChanges();
        }