public TokenController( ApplicationDbContext context, IUltraRepository repo, IConfiguration configuration) : base(context, repo, configuration) { }
public static void Seed(ApplicationDbContext dbContext, IUltraRepository repo) { if (!dbContext.Users.Any()) { CreateApplicationRolesAndAdminUser(dbContext, repo) .GetAwaiter() .GetResult(); } }
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 }; }
public EntityDataTypeLogic(IUltraRepository ultraRepository) { this.UltraRepository = ultraRepository; }
public AccountController(IUltraRepository ultraRepository) { this.ultraRepository = ultraRepository; this.AppSettings = this.AppSettings; }
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(); }