public Dal() { var optionsBuilder = new DbContextOptionsBuilder <LeafContext>(); optionsBuilder.UseSqlServer(Configuration.GetConnectionString("LeafDB")); SetBDD(bdd = new LeafContext(optionsBuilder.Options)); }
public HomeController(UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IEmailSender emailSender, ILogger <AccountController> logger, LeafContext context) { new Dal().SetAndInitBDD(context, userManager, signInManager); }
public static async void SetAndInitBDD(this Dal dal, LeafContext leafContext, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager) { if (!userManagerLoaded) { //Cleaning previous data loaded Dal.SetBDD(leafContext); var optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>(); optionsBuilder.UseSqlServer(Dal.Configuration.GetConnectionString("DefaultConnection")); //If logged in if (signInManager.Context.User.Identity.IsAuthenticated) { await signInManager.SignOutAsync(); } using (var context = new ApplicationDbContext(optionsBuilder.Options)) { foreach (ApplicationUser user in context.Users) { try { await userManager.DeleteAsync(user); } catch (Exception) { } } } var l = leafContext.Collaborateurs.ToList(); foreach (Collaborateurs c in l) { var user = new ApplicationUser { UserName = c.Mail, Email = c.Mail }; try { var result = await userManager.CreateAsync(user, c.Mdp); if (!result.Succeeded) { foreach (IdentityError e in result.Errors) { Console.Write("ERRRREUUUUURRRSS ########### "); Console.WriteLine(e.Description); //La console n'affichera rien } } } catch (Exception) { } } userManagerLoaded = true; } }
public static void SetBDD(LeafContext leafContext) { //bdd = leafContext; ////Refreshing singletons //adminService = new AdminService(bdd); //clientService = new ClientService(bdd); //collaborateursService = new CollaborateursService(bdd); //notificationService = new NotificationService(bdd); //projetService = new ProjetService(bdd); //tacheService = new TacheService(bdd); }
public ClientCreationController(LeafContext context) { Dal.SetBDD(context); }
public ProjectsController(LeafContext context) { Dal.SetBDD(context); }
public TacheService(LeafContext context) : base(context) { }
public ProjetService(LeafContext context) : base(context) { }
public NotificationService(LeafContext context) : base(context) { }
public Startup(IConfiguration configuration) { Configuration = configuration; Dal.Configuration = configuration; LeafContext.SetConfiguration(configuration); }
public ClientService(LeafContext context) : base(context) { }
public AdminService(LeafContext context) : base(context) { }
public Dal() { bdd = new LeafContext(new Microsoft.EntityFrameworkCore.DbContextOptions <LeafContext>()); }
public ClientsController(LeafContext context) { Dal.SetBDD(context); }
public CollaborateursService(LeafContext context) : base(context) { }
public TaskController(LeafContext context) { Dal.SetBDD(context); }
public ProfileController(LeafContext context) { Dal.SetBDD(context); }