Ejemplo n.º 1
0
 public DelegationBuilderCommitteeSelector(MunityContext context, string conferenceId, int countryId, Delegation delegation)
 {
     this._dbContext    = context;
     this._conferenceId = conferenceId;
     this.Delegation    = delegation;
     this._countryId    = countryId;
 }
Ejemplo n.º 2
0
        public void SetupTests()
        {
            var loggerMock = new Mock <ILogger <ResolutionService> >();

            dbContext = TestHelpers.CreateSQLiteContext("resolutiontests");
            service   = new ResolutionService(dbContext, loggerMock.Object);
        }
Ejemplo n.º 3
0
        //public async Task<object> Login(MunityUser user)
        //{
        //    var signIn = await signInManager.SignIn(user, true);
        //}

        public UserService(MunityContext context, UserManager <MunityUser> userManager, IMailService mailService, ILogger <UserService> logger)
        {
            this.context      = context;
            this.userManager  = userManager;
            this._logger      = logger;
            this._mailService = mailService;
        }
Ejemplo n.º 4
0
    public void SetupDatabase()
    {
        var serviceCollection = new ServiceCollection();

        serviceCollection.AddDbContext <MunityContext>(options =>
                                                       options.UseSqlite("Data Source=testmunbw.db"));

        serviceCollection.AddIdentity <MunityUser, MunityRole>(options =>
        {
            options.User.RequireUniqueEmail         = true;
            options.Password.RequireDigit           = true;
            options.Password.RequireLowercase       = true;
            options.Password.RequireUppercase       = true;
            options.Password.RequireNonAlphanumeric = false;
        })
        .AddEntityFrameworkStores <MunityContext>();

        // Needed to get the Identity Provider to run!
        serviceCollection.AddLogging();

        this._serviceProvider = serviceCollection.BuildServiceProvider();

        // Reset the Database.
        _context = _serviceProvider.GetRequiredService <MunityContext>();
        _context.Database.EnsureDeleted();
        _context.Database.EnsureCreated();
    }
Ejemplo n.º 5
0
    public void Setup()
    {
        var optionsBuilder = new DbContextOptionsBuilder <MunityContext>();

        optionsBuilder.UseSqlite("Data Source=test_conference.db");
        _context = new MunityContext(optionsBuilder.Options);
        _context.Database.EnsureDeleted();
        _context.Database.EnsureCreated();
    }
Ejemplo n.º 6
0
    public void Setup()
    {
        // Datenbank für den Test erzeugen und falls vorhanden erst einmal leeren und neu erstellen!
        var optionsBuilder = new DbContextOptionsBuilder <MunityContext>();

        optionsBuilder.UseSqlite("Data Source=test_conference.db");
        _context = new MunityContext(optionsBuilder.Options);
        ResetDatabase();
    }
Ejemplo n.º 7
0
    public static int SetupBaseRoles(this MunityContext context)
    {
        if (!context.Roles.Any())
        {
            foreach (var munityRole in BaseData.DefaultAuthorizations.UserRoles)
            {
                context.Roles.Add(munityRole);
            }
        }

        return(context.SaveChanges());
    }
Ejemplo n.º 8
0
    public static MunityContext CreateSQLiteContext(string name)
    {
        // Datenbank für den Test erzeugen und falls vorhanden erst einmal leeren und neu erstellen!
        var optionsBuilder = new DbContextOptionsBuilder <MunityContext>();

        optionsBuilder.UseSqlite($"Data Source={name}.db");
        var context = new MunityContext(optionsBuilder.Options);

        context.Database.EnsureDeleted();
        context.Database.EnsureCreated();
        return(context);
    }
Ejemplo n.º 9
0
 public RegisterModel(
     UserManager <MunityUser> userManager,
     SignInManager <MunityUser> signInManager,
     ILogger <RegisterModel> logger,
     IMailService emailSender,
     MunityContext context)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _logger        = logger;
     _emailSender   = emailSender;
     _dbContext     = context;
 }
Ejemplo n.º 10
0
        public DelegationApplicationBuilder(MunityContext context, string conferenceId)
        {
            this._context     = context;
            this.conferenceId = conferenceId;

            this.application = new DelegationApplication()
            {
                DelegationWishes = new List <DelegationApplicationPickedDelegation>(),
                Users            = new List <DelegationApplicationUserEntry>(),
                FormulaInputs    = new List <ConferenceDelegationApplicationFieldInput>(),
                ApplyDate        = DateTime.Now,
                OpenToPublic     = false,
                Status           = ApplicationStatuses.Writing,
                Conference       = context.Conferences.Find(conferenceId)
            };
        }
Ejemplo n.º 11
0
        public DelegationBuilder(MunityContext context, string conferenceId)
        {
            this._dbContext    = context;
            this._conferenceId = conferenceId;
            var conference = _dbContext.Conferences.Find(conferenceId);

            if (conference == null)
            {
                throw new ConferenceNotFoundException($"No conference with the id {conferenceId} found!");
            }

            this.Delegation = new Delegation()
            {
                Conference = conference,
                Roles      = new List <ConferenceDelegateRole>()
            };
        }
Ejemplo n.º 12
0
    public void Setup()
    {
        // Datenbank für den Test erzeugen und falls vorhanden erst einmal leeren und neu erstellen!
        var optionsBuilder = new DbContextOptionsBuilder <MunityContext>();

        optionsBuilder.UseSqlite("Data Source=test_conferenceRoles.db");
        _context = new MunityContext(optionsBuilder.Options);
        _context.Database.EnsureDeleted();
        _context.Database.EnsureCreated();

        organization = new Organization()
        {
            OrganizationName  = "Test Organization",
            OrganizationShort = "TO"
        };
        project = new Project()
        {
            ProjectName         = "Test Project",
            ProjectOrganization = organization,
            ProjectShort        = "TP",
        };
        conference = new Conference()
        {
            ConferenceProject = project,
            ConferenceShort   = "TC",
            CreationDate      = DateTime.Now,
            EndDate           = new DateTime(2021, 1, 4),
            StartDate         = new DateTime(2021, 1, 1),
            FullName          = "Test Conference",
            Name = "Test Conference"
        };
        var committee = new Committee()
        {
            Article        = "die",
            CommitteeShort = "GV",
            Conference     = conference,
            FullName       = "Generalversammlung",
            Name           = "Generalversammlung"
        };

        _context.Organizations.Add(organization);
        _context.Projects.Add(project);
        _context.Conferences.Add(conference);
        _context.Committees.Add(committee);
        _context.SaveChanges();
    }
Ejemplo n.º 13
0
    /// <summary>
    /// Adds the countries that are given to the Database. If a country already has the given name it
    /// will just update the country.
    /// </summary>
    /// <param name="context"></param>
    /// <param name="countries"></param>
    /// <returns></returns>
    public static int AddBaseCountries(this MunityContext context, IEnumerable <Country> countries)
    {
        foreach (var country in countries)
        {
            var matchingCountry = context.Countries.Include(n => n.Translations).FirstOrDefault(n =>
                                                                                                n.Name == country.Name);
            if (matchingCountry != null)
            {
                // Update the country
                matchingCountry.FullName = country.FullName;
                matchingCountry.Iso      = country.Iso;
                if (country.Continent != EContinent.NotSet)
                {
                    matchingCountry.Continent = country.Continent;
                }

                if (country.Translations.Count > 0)
                {
                    foreach (var translation in country.Translations)
                    {
                        var foundTranslation =
                            matchingCountry.Translations.FirstOrDefault(n =>
                                                                        n.LanguageCode == translation.LanguageCode);
                        if (foundTranslation != null)
                        {
                            foundTranslation.TranslatedName     = translation.TranslatedName;
                            foundTranslation.TranslatedFullName = translation.TranslatedFullName;
                        }
                    }
                }
            }
            else
            {
                context.Countries.Add(country);
            }
        }

        return(context.SaveChanges());
    }
Ejemplo n.º 14
0
 public ResolutionService(MunityContext context, ILogger <ResolutionService> logger)
 {
     this._context = context;
     this._logger  = logger;
 }
Ejemplo n.º 15
0
 public void Dispose()
 {
     this._context?.Dispose();
     this._context = null;
     _logger.LogDebug("A ResolutionService has been disposed!");
 }
 public ConferenceApplicationService(MunityContext context, ILogger <ConferenceApplicationService> logger)
 {
     this._dbContext = context;
     this._logger    = logger;
 }
Ejemplo n.º 17
0
 public OrganizationTools(MunityContext context)
 {
     this.DbContext = context;
 }
Ejemplo n.º 18
0
 public ConferenceOptionsBuilder(MunityContext context, Project project = null)
 {
     this._conference = new Conference();
     this._context    = context;
     this._conference.ConferenceProject = project;
 }
Ejemplo n.º 19
0
 public void SetUp()
 {
     this._context = MunityContext.FromSqlLite("settingTest");
     _context.Database.EnsureDeleted();
     _context.Database.EnsureCreated();
 }
Ejemplo n.º 20
0
 public ProjectTools(MunityContext context)
 {
     _dbContext = context;
 }
Ejemplo n.º 21
0
 public CommitteeSpecificTools(MunityContext context, [NotNull] string committeeId)
 {
     this._dbContext   = context;
     this._committeeId = committeeId;
 }
Ejemplo n.º 22
0
 public ConferenceWebsiteService(MunityContext context)
 {
     _context = context;
 }
 public OrganizationOptionsBuilder(MunityContext context)
 {
     this._context     = context;
     this.Organization = new Organization();
 }
Ejemplo n.º 24
0
 public BuildReadyDelegationBuilder(MunityContext context, Delegation delegation)
 {
     this._context   = context;
     this.Delegation = delegation;
 }
Ejemplo n.º 25
0
 public UserConferenceAuthService(MunityContext context, UserManager <MunityUser> userManager)
 {
     this.context     = context;
     this.userManager = userManager;
 }
Ejemplo n.º 26
0
 public ConferenceService(MunityContext context, UserConferenceAuthService authService, ILogger <ConferenceService> logger)
 {
     this.context     = context;
     this.authService = authService;
     this._logger     = logger;
 }
Ejemplo n.º 27
0
 public ProjectOptionsBuilder(MunityContext context, Organization organization = null)
 {
     this.Project  = new Project();
     this._context = context;
     this.Project.ProjectOrganization = organization;
 }
Ejemplo n.º 28
0
 public FluentProvider(MunityContext context)
 {
     this.DbContext = context;
 }
Ejemplo n.º 29
0
 public void ReloadContextToClearBuffer()
 {
     _context = _serviceProvider.GetRequiredService <MunityContext>();
 }
Ejemplo n.º 30
0
 public ConferenceTools(MunityContext context)
 {
     this._dbContext = context;
 }