Пример #1
0
        /// <summary>
        /// Seed data into the table
        /// </summary>
        /// <param name="context">DbContext</param>
        public static void Seed(this TrappistDbContext context)
        {
            if (context.CodingLanguage.Any())
            {
                return;
            }

            var Languages = new CodingLanguage[]
            {
                new CodingLanguage {
                    Language = ProgrammingLanguage.Java.ToString()
                },
                new CodingLanguage {
                    Language = ProgrammingLanguage.Cpp.ToString()
                },
                new CodingLanguage {
                    Language = ProgrammingLanguage.C.ToString()
                }
            };

            foreach (CodingLanguage language in Languages)
            {
                context.CodingLanguage.Add(language);
            }

            context.SaveChanges();
        }
Пример #2
0
        public static void ClearDatabaseAndSeed(TrappistDbContext dbContext)
        {
            dbContext.Database.EnsureDeleted();
            //seed data will go here.
            var Languages = new CodingLanguage[]
            {
                new CodingLanguage {
                    Language = ProgrammingLanguage.Java.ToString()
                },
                new CodingLanguage {
                    Language = ProgrammingLanguage.Cpp.ToString()
                },
                new CodingLanguage {
                    Language = ProgrammingLanguage.C.ToString()
                }
            };

            foreach (CodingLanguage language in Languages)
            {
                dbContext.CodingLanguage.Add(language);
            }

            dbContext.SaveChanges();
        }
Пример #3
0
 public void UpdateUserProfile(ApplicationUser updateUserDetails)
 {
     _dbContext.Users.Update(updateUserDetails);
     _dbContext.SaveChanges();
 }