コード例 #1
0
ファイル: DbInitializer.cs プロジェクト: Rezgui16/GustoGlobal
        public static async Task InitializeAsync(GustoDbContext context, IServiceProvider serviceProvider)
        {
            var RoleManager = serviceProvider.GetRequiredService <RoleManager <IdentityRole> >();

            string[]       roleNames = { "Admin", "Chef", "User" };
            IdentityResult roleResult;

            foreach (var roleName in roleNames)
            {
                var roleExist = await RoleManager.RoleExistsAsync(roleName);

                if (!roleExist)
                {
                    roleResult = await RoleManager.CreateAsync(new IdentityRole(roleName));
                }
            }

            //var UserManager = serviceProvider.GetRequiredService <UserManager<User>>();
            //var SignInManager = serviceProvider.GetRequiredService<SignInManager<User>>();
            //if (!await UserManager.GetUserName([email protected])) { }
            //    var user = new User()
            //{
            //    UserName = "******",
            //    Email = "*****@*****.**",
            //    LastName = "jeff",
            //    FirstMidName = "test"
            //};
            //await UserManager.AddToRoleAsync(user, "User");
            //await SignInManager.SignInAsync(user, isPersistent: false);
        }
コード例 #2
0
 public BaseController(GustoDbContext context)
 {
     _context = context;
 }
コード例 #3
0
 public RecettesController(GustoDbContext context) : base(context)
 {
 }
コード例 #4
0
 public EtapesController(GustoDbContext context) : base(context)
 {
 }
コード例 #5
0
 public CategoriesController(GustoDbContext context) : base(context)
 {
 }
コード例 #6
0
 public AvisController(GustoDbContext context) : base(context)
 {
 }
コード例 #7
0
 public DashboardController(GustoDbContext context) : base(context)
 {
 }
コード例 #8
0
 public NotesController(GustoDbContext context) : base(context)
 {
 }
コード例 #9
0
 public ComposersController(GustoDbContext context) : base(context)
 {
 }
コード例 #10
0
 public FavorisController(GustoDbContext context) : base(context)
 {
 }
コード例 #11
0
 public RecettesController(GustoDbContext context)
 {
     _context = context;
 }
コード例 #12
0
 public IngredientsController(GustoDbContext context) : base(context)
 {
 }
コード例 #13
0
 public HomeController(GustoDbContext context) : base(context)
 {
 }