Ejemplo n.º 1
0
        public static void InitializeDatabase()
        {
            var database    = new OpaContext();
            var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(database));
            var ownerUser   = userManager.FindByName(OwnerEmail);

            if (ownerUser == null)
            {
                var user = new ApplicationUser
                {
                    UserName       = OwnerEmail,
                    Email          = OwnerEmail,
                    EmailConfirmed = true
                };

                var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(database));
                if (!roleManager.Roles.Any())
                {
                    roleManager.Create(new IdentityRole {
                        Name = "Admin"
                    });
                    roleManager.Create(new IdentityRole {
                        Name = "User"
                    });
                }

                userManager.Create(user, DateTime.Now.ToString(CultureInfo.InvariantCulture));
                userManager.AddToRole(user.Id, "Admin");
            }
        }
Ejemplo n.º 2
0
 protected BaseController()
 {
     Logger = LogManager.GetLogger(GetType());
     Database = new OpaContext();
     PersonHelper = new PersonLogic(Database);
     UserHelper = new UserLogic(Database, PersonHelper);
     PaymentHelper = new PaymentLogic(Database, PersonHelper);
     ContactHelper = new ContactLogic(Database);
     FinancialHelper = new FinancialLogic(Database);
 }
Ejemplo n.º 3
0
 public ContactLogic(OpaContext database)
 {
     Database = database;
 }
Ejemplo n.º 4
0
 public PaymentLogic(OpaContext database, PersonLogic personHelper)
 {
     Database     = database;
     PersonHelper = personHelper;
 }
Ejemplo n.º 5
0
 public FinancialLogic(OpaContext database)
 {
     Database = database;
 }
Ejemplo n.º 6
0
 public PersonLogic(OpaContext database)
 {
     Database = database;
 }
Ejemplo n.º 7
0
 public UserLogic(OpaContext database, PersonLogic personHelper)
 {
     Database     = database;
     PersonHelper = personHelper;
 }