Exemplo n.º 1
0
 public TokenController(
     ApplicationDbContext context,
     IUltraRepository repo,
     IConfiguration configuration)
     : base(context, repo, configuration)
 {
 }
Exemplo n.º 2
0
 public static void Seed(ApplicationDbContext dbContext, IUltraRepository repo)
 {
     if (!dbContext.Users.Any())
     {
         CreateApplicationRolesAndAdminUser(dbContext, repo)
         .GetAwaiter()
         .GetResult();
     }
 }
Exemplo n.º 3
0
        public BaseApiController(
            ApplicationDbContext context,
            IUltraRepository repo,
            IConfiguration configuration)
        {
            // Instantiate the required classes through DI
            this.DbContext     = context;
            this.Repository    = repo;
            this.Configuration = configuration;

            // Instantiate a single JsonSerializerSettings object
            // that can be reused multiple times.
            this.JsonSettings = new JsonSerializerSettings()
            {
                Formatting = Formatting.Indented
            };
        }
Exemplo n.º 4
0
 public EntityDataTypeLogic(IUltraRepository ultraRepository)
 {
     this.UltraRepository = ultraRepository;
 }
Exemplo n.º 5
0
 public AccountController(IUltraRepository ultraRepository)
 {
     this.ultraRepository = ultraRepository;
     this.AppSettings     = this.AppSettings;
 }
Exemplo n.º 6
0
        public static async Task CreateApplicationRolesAndAdminUser(ApplicationDbContext dbContext, IUltraRepository repo)
        {
            List <ApplicationRole> rolesList = new List <ApplicationRole>
            {
                // roles are adding here
                new ApplicationRole {
                    Id = "1", Name = "SystemAdministrator", NormalizedName = "SystemAdministrator"
                },
                new ApplicationRole {
                    Id = "2", Name = "Doctor", NormalizedName = "Doctor"
                },
                new ApplicationRole {
                    Id = "3", Name = "Patient", NormalizedName = "Patient"
                }
            };

            foreach (ApplicationRole role in rolesList)
            {
                if (!await repo.RoleExistsAsync(role.Name))
                {
                    await repo.CreateRolesAsync(role);
                }
            }

            ApplicationUser user_Admin = new ApplicationUser
            {
                SecurityStamp      = Guid.NewGuid().ToString(),
                UserName           = "******",
                Email              = "*****@*****.**",
                NormalizedUserName = "******"
            };

            if (await repo.FindUserByEmailAsync(user_Admin.Email) == null)
            {
                await repo.CreateUserAsync(user_Admin, "Diplo1!");

                await repo.AddUserDefaultRoleAsync(user_Admin, "SystemAdministrator");

                // Remove Lockout and E-Mail confirmation.
                user_Admin.EmailConfirmed = true;
                user_Admin.LockoutEnabled = false;
            }

            await dbContext.SaveChangesAsync();
        }