Example #1
0
        public T ExecuteDb <T>(Func <ThreesixtyContext, T> invoke)
        {
            T result;

            using (var context = new ThreesixtyContext(DbOptions))
            {
                using (var tr = context.Database.BeginTransaction())
                {
                    result = invoke.Invoke(context);
                    context.SaveChanges();
                    tr.Commit();
                }
            }

            return(result);
        }
Example #2
0
        public static void Initialize(ThreesixtyContext context)
        {
            context.Database.EnsureCreated();

            // Adding first user
            if (!context.Users.Any())
            {
                var regInfo = new RegisterInfo
                {
                    Username        = "******",
                    Fullname        = "Admin",
                    Password        = "******",
                    PasswordConfirm = "admin123"
                };

                var user = UserManager.CreateUser(regInfo);
                context.Users.Add(user);
            }

            context.SaveChanges();
        }