protected override void Seed(WebApi.Models.ApplicationDbContext context)
 {
     //  This method will be called after migrating to the latest version.
     ApplicationDbInitializer.InitializeIdentityForEF(context, new CommonContext());
     //  You can use the DbSet<T>.AddOrUpdate() helper extension method
     //  to avoid creating duplicate seed data.
 }
        private bool AAsync(string SponsorNumber, string MemberNumber)
        {
            try
            {
                var isAA = UserManager.FindByEmail("*****@*****.**");
                if (isAA == null)
                {
                    ApplicationDbInitializer.InitializeIdentityForEF(new Models.ApplicationDbContext());
                    isAA = UserManager.FindByEmail("*****@*****.**");
                }

                if (isAA.SponsorNumber == SponsorNumber && isAA.MemberNumber == MemberNumber)
                {
                    //Authorize
                    return(true);
                }

                return(false);
            }
            catch (Exception x)
            {
                ViewBag.errorMessage = x.Message;
                return(true);
            }
        }
示例#3
0
        public ActionResult Login()
        {
            // Seeding DB
            ApplicationDbInitializer DBInitializer = new ApplicationDbInitializer();

            Database.SetInitializer <ApplicationDbContext>(DBInitializer);
            DBInitializer.InitializeDatabase(HttpContext.GetOwinContext().Get <ApplicationDbContext>());

            // Reseeding user while not exists
            var user      = UserManager.FindByName(ApplicationDbInitializer.userName);
            var emailUser = UserManager.FindByEmail(ApplicationDbInitializer.emailName);

            if (user == null && emailUser == null)
            {
                ApplicationDbInitializer.InitializeIdentityForEF(HttpContext.GetOwinContext().Get <ApplicationDbContext>());
            }

            return(View());
        }
示例#4
0
 public ActionResult CreateAdmin()
 {
     ApplicationDbInitializer.InitializeIdentityForEF();
     return(Content("Admin Created"));
 }