Example #1
0
        public Dal()
        {
            var optionsBuilder = new DbContextOptionsBuilder <LeafContext>();

            optionsBuilder.UseSqlServer(Configuration.GetConnectionString("LeafDB"));
            SetBDD(bdd = new LeafContext(optionsBuilder.Options));
        }
Example #2
0
 public HomeController(UserManager <ApplicationUser> userManager,
                       SignInManager <ApplicationUser> signInManager,
                       IEmailSender emailSender,
                       ILogger <AccountController> logger,
                       LeafContext context)
 {
     new Dal().SetAndInitBDD(context, userManager, signInManager);
 }
Example #3
0
        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;
            }
        }
Example #4
0
        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);
 }
Example #7
0
 public TacheService(LeafContext context) : base(context)
 {
 }
Example #8
0
 public ProjetService(LeafContext context) : base(context)
 {
 }
Example #9
0
 public NotificationService(LeafContext context) : base(context)
 {
 }
Example #10
0
 public Startup(IConfiguration configuration)
 {
     Configuration     = configuration;
     Dal.Configuration = configuration;
     LeafContext.SetConfiguration(configuration);
 }
Example #11
0
 public ClientService(LeafContext context) : base(context)
 {
 }
Example #12
0
 public AdminService(LeafContext context) : base(context)
 {
 }
Example #13
0
 public Dal()
 {
     bdd = new LeafContext(new Microsoft.EntityFrameworkCore.DbContextOptions <LeafContext>());
 }
 public ClientsController(LeafContext context)
 {
     Dal.SetBDD(context);
 }
Example #15
0
 public CollaborateursService(LeafContext context) : base(context)
 {
 }
Example #16
0
 public TaskController(LeafContext context)
 {
     Dal.SetBDD(context);
 }
 public ProfileController(LeafContext context)
 {
     Dal.SetBDD(context);
 }