// Constructor
 public BedrijfRepository(InternshipContext context)
 {
     this.context = context;
     bedrijven = context.Bedrijven;
     opdrachten = context.Opdrachten;
     contactpersonen = context.ContactPersonen;
 }
 public UserRepository(InternshipContext context)
 {
     this.Context = context;
     this.Users = context.Users;
     this.Manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context));
     this.RoleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(context));
     UserValidator<ApplicationUser> userValidator = Manager.UserValidator as UserValidator<ApplicationUser>;
     userValidator.AllowOnlyAlphanumericUserNames = false;
 }
Beispiel #3
0
        internal static InternshipContext GetDatabaseContext()
        {
            var options = new DbContextOptionsBuilder <InternshipContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;
            var databaseContext = new InternshipContext(options);

            databaseContext.Database.EnsureCreated();
            return(databaseContext);
        }
Beispiel #4
0
        private void SetupDatabase(IApplicationBuilder app)
        {
            var connection = Configuration.GetConnectionString("InternshipContext");

            InternshipContext.SetConnectionString(connection);
            //using (var serviceScope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())
            //{
            //var context = serviceScope.ServiceProvider.GetRequiredService<InternshipContext>();
            //context.Database.Migrate();
            //context.DropCreateDatabaseIfModelChanges<InternshipContext>.Seed();
            //}
        }
 public PeopleController(InternshipContext context, UserManager <ApplicationUser> userManager, RoleManager <ApplicationRole> roleManager)
 {
     _context         = context;
     this.userManager = userManager;
     this.roleManager = roleManager;
 }
 // Constructor
 public StagebegeleiderRepository(InternshipContext context)
 {
     this.context = context;
     stagebegeleiders = context.Stagebegeleiders;
 }
Beispiel #7
0
 public InternshipService(InternshipContext context)
 {
     _context = context;
 }
 public ContactPersoonRepository(InternshipContext con)
 {
     this.context = con;
     contactpersonen = context.ContactPersonen;
 }
 public StatusRepository(InternshipContext context)
 {
     this.context = context;
     statussen = context.Statussen;
 }
Beispiel #10
0
 public HospitalController(InternshipContext context)
 {
     _context = context;
 }
 // Constructor
 public StudentRepository(InternshipContext context)
 {
     this.context = context;
     studenten = context.Studenten;
 }
Beispiel #12
0
 public UniversityController(InternshipContext context)
 {
     _context = context;
 }
Beispiel #13
0
 public SelectedHospitalLogController(InternshipContext context)
 {
     _context = context;
 }
        public void Setup()
        {
            _context = ContextHelper.GetDatabaseContext();

            moqInternshipService = new Mock <IInternshipService>();
            moqUserService       = new Mock <IUserService>();

            userTeacher = new User
            {
                Id           = Guid.NewGuid(),
                City         = "City",
                Email        = "*****@*****.**",
                FirstName    = "John",
                HouseNumber  = 18,
                LastName     = "Doe",
                PasswordHash = Guid.NewGuid().ToString(),
                PhoneNumber  = "+3259874896",
                ZipCode      = 7890,
                UserName     = "******",
                StreetName   = "Easy Street"
            };

            internship = new Internship
            {
                RequiredFieldsOfStudy  = new List <string>(),
                AssignedStudents       = new List <string>(),
                Environment            = new List <string>(),
                TechnicalDescription   = "TechnicalDescription",
                ExtraRequirements      = "ExtraRequirements",
                ResearchTheme          = "ResearchTheme",
                Activities             = new List <string>(),
                RequiredStudentsAmount = 2,
                AdditionalRemarks      = "AdditionalRemarks",
                Id = Guid.NewGuid(),
                InternshipState = 0,
                Periods         = new List <string>(),
                Description     = "Description",
                DateOfState     = DateTime.UtcNow,
            };

            roleTeacher = new Role
            {
                Id             = Guid.NewGuid(),
                Name           = "Teacher",
                NormalizedName = "TEACHER"
            };

            ReviewerInternships reviewerInternships = new ReviewerInternships
            {
                ReviewedInternship = internship,
                Reviewer           = userTeacher
            };

            reviewerList = new List <ReviewerInternships> {
                reviewerInternships
            };

            internship.Reviewers = reviewerList;

            var store = new Mock <IUserStore <User> >();


            moqUserManager = new Mock <UserManager <User> >(store.Object, null, null, null, null, null, null, null, null);

            moqUserManager.Object.UserValidators.Add(new UserValidator <User>());
            moqUserManager.Object.PasswordValidators.Add(new PasswordValidator <User>());



            sut = new InternshipController(moqInternshipService.Object, moqUserService.Object, moqUserManager.Object);

            assignDto = new InternshipAssign
            {
                InternshipID = Guid.NewGuid(),
                Teachers     = new List <Guid> {
                    Guid.NewGuid()
                }
            };

            _context.Add(userTeacher);
            _context.Roles.Add(roleTeacher);
            _context.UserRoles.Add(new IdentityUserRole <Guid>
            {
                RoleId = roleTeacher.Id,
                UserId = userTeacher.Id
            });

            _context.SaveChanges();
        }
 public OpdrachtenRepository(InternshipContext context)
 {
     this.Context = context;
     this.Opdrachten = context.Opdrachten;
 }
 public SpecialisatieRepository(InternshipContext context)
 {
     this.context = context;
     this.specialisaties = context.Specialisaties;
 }
Beispiel #17
0
        public void Setup()
        {
            _context = ContextHelper.GetDatabaseContext();

            sut = new InternshipService(_context);

            dto = new InternshipCreationDto
            {
                RequiredFieldsOfStudy  = new List <string>(),
                AssignedStudents       = new List <string>(),
                Environment            = new List <string>(),
                TechnicalDescription   = "TechnicalDescription",
                ExtraRequirements      = "ExtraRequirements",
                ResearchTheme          = "ResearchTheme",
                Activities             = new List <string>(),
                RequiredStudentsAmount = 2,
                AdditionalRemarks      = "AdditionalRemarks",
                PeriodOfInternship     = new List <string>(),
                Description            = "Description"
            };

            for (int i = 0; i < 10; i++)
            {
                dto.RequiredFieldsOfStudy.Add("ReqFOS" + i);
                dto.AssignedStudents.Add("AssignedStudent" + i);
                dto.Environment.Add("Environment" + i);
                dto.Activities.Add("Activity" + i);
                dto.PeriodOfInternship.Add("Period" + i);
            }

            internship = new Internship
            {
                CreatorId              = Guid.NewGuid(),
                RequiredFieldsOfStudy  = dto.RequiredFieldsOfStudy,
                AssignedStudents       = dto.AssignedStudents,
                Environment            = dto.Environment,
                TechnicalDescription   = "TechnicalDescription",
                ExtraRequirements      = "ExtraRequirements",
                ResearchTheme          = "ResearchTheme",
                Activities             = dto.Activities,
                RequiredStudentsAmount = 2,
                AdditionalRemarks      = "AdditionalRemarks",
                Id = Guid.NewGuid(),
                InternshipState = 0,
                Periods         = dto.PeriodOfInternship,
                Description     = "Description",
                DateOfState     = DateTime.UtcNow
            };

            userTeacher = new User
            {
                Id           = Guid.NewGuid(),
                City         = "City",
                Email        = "*****@*****.**",
                FirstName    = "John",
                HouseNumber  = 18,
                LastName     = "Doe",
                PasswordHash = Guid.NewGuid().ToString(),
                PhoneNumber  = "+3259874896",
                ZipCode      = 7890,
                UserName     = "******",
                StreetName   = "Easy Street"
            };

            userTeacher2 = new User
            {
                Id           = Guid.NewGuid(),
                City         = "City",
                Email        = "*****@*****.**",
                FirstName    = "John",
                HouseNumber  = 18,
                LastName     = "Doe",
                PasswordHash = Guid.NewGuid().ToString(),
                PhoneNumber  = "+3259874896",
                ZipCode      = 7890,
                UserName     = "******",
                StreetName   = "Easy Street"
            };

            company = new Company
            {
                Id = internship.CreatorId
            };


            ReviewerInternships reviewerInternships = new ReviewerInternships
            {
                ReviewedInternship = internship,
                Reviewer           = userTeacher
            };

            reviewerList = new List <ReviewerInternships> {
                reviewerInternships
            };

            internship.Reviewers = reviewerList;

            IFCDto = new InternshipFeedbackCoordinatorDto
            {
                Feedback      = "coordinator",
                InternshipId  = internship.Id,
                ReviewedState = InternshipState.ApprovedByAll
            };

            IFTDto = new InternshipFeedbackTeacherDto
            {
                Feedback     = "teacher",
                InternshipId = internship.Id,
                TeacherId    = userTeacher.Id
            };

            updateDto = new InternshipUpdate
            {
                ID            = internship.Id,
                ResearchTheme = "ResearchTheme",
                Description   = "DescriptionUpdate",
                Activities    = new List <string>()
                {
                    "test"
                },
                AdditionalRemarks = "test",
                AssignedStudents  = new List <string>()
                {
                    "Jan"
                },
                Environment = new List <string>()
                {
                    "test"
                },
                ExtraRequirements  = "test",
                PeriodOfInternship = new List <string>()
                {
                    "test"
                },
                RequiredFieldsOfStudy = new List <string>()
                {
                    "AON"
                },
                RequiredStudentsAmount = 1,
                TechnicalDescription   = "test",
                Title = "test"
            };

            _context.Add(reviewerInternships);
            _context.Add(userTeacher);
            _context.Add(internship);
            _context.SaveChanges();
        }
Beispiel #18
0
        public void Setup()
        {
            _context = ContextHelper.GetDatabaseContext();

            sut = new UserService(_context);

            userTeacher = new User
            {
                Id           = Guid.NewGuid(),
                City         = "City",
                Email        = "*****@*****.**",
                FirstName    = "John",
                HouseNumber  = 18,
                LastName     = "Doe",
                PasswordHash = Guid.NewGuid().ToString(),
                PhoneNumber  = "+3259874896",
                ZipCode      = 7890,
                UserName     = "******",
                StreetName   = "Easy Street",
                IsValidated  = false
            };

            company = new Company
            {
                CompanyTitle = "Test inc."
            };

            dtoTeacher = new UserReadDto
            {
                FirstName = userTeacher.FirstName,
                LastName  = userTeacher.LastName,
                Id        = userTeacher.Id
            };

            userCompany = new User
            {
                Id           = Guid.NewGuid(),
                City         = "City",
                Email        = "*****@*****.**",
                FirstName    = "Johnnie",
                HouseNumber  = 19,
                LastName     = "Doe",
                PasswordHash = Guid.NewGuid().ToString(),
                PhoneNumber  = "+3259874896",
                ZipCode      = 7890,
                UserName     = "******",
                StreetName   = "Easy Street",
                IsValidated  = false
            };

            dtoCompany = new UserReadDto
            {
                FirstName = userCompany.FirstName,
                LastName  = userCompany.LastName,
                Id        = userCompany.Id
            };

            userStudent = new User
            {
                Id           = Guid.NewGuid(),
                City         = "City",
                Email        = "*****@*****.**",
                FirstName    = "Henk",
                HouseNumber  = 17,
                LastName     = "Doe",
                PasswordHash = Guid.NewGuid().ToString(),
                PhoneNumber  = "+3259874896",
                ZipCode      = 7890,
                UserName     = "******",
                StreetName   = "Easy Street",
                IsValidated  = false
            };

            dtoStudent = new UserReadDto
            {
                FirstName = userStudent.FirstName,
                LastName  = userStudent.LastName,
                Id        = userStudent.Id
            };

            roleCompany = new Role
            {
                Id             = Guid.NewGuid(),
                Name           = "Company",
                NormalizedName = "COMPANY"
            };

            roleStudent = new Role
            {
                Id             = Guid.NewGuid(),
                Name           = "Student",
                NormalizedName = "STUDENT"
            };

            roleTeacher = new Role
            {
                Id             = Guid.NewGuid(),
                Name           = "Teacher",
                NormalizedName = "TEACHER"
            };

            internship = new Internship
            {
                RequiredFieldsOfStudy  = new List <string>(),
                AssignedStudents       = new List <string>(),
                Environment            = new List <string>(),
                TechnicalDescription   = "TechnicalDescription",
                ExtraRequirements      = "ExtraRequirements",
                ResearchTheme          = "ResearchTheme",
                Activities             = new List <string>(),
                RequiredStudentsAmount = 2,
                AdditionalRemarks      = "AdditionalRemarks",
                Periods         = new List <string>(),
                Description     = "Description",
                DateCreated     = DateTime.UtcNow,
                DateOfState     = DateTime.UtcNow,
                Id              = Guid.NewGuid(),
                InternshipState = 0,
                Reviewers       = new List <ReviewerInternships> {
                    new ReviewerInternships
                    {
                        ReviewedInternship = internship,
                        Reviewer           = userTeacher
                    }
                }
            };

            updateUser = new UserUpdate
            {
                FieldOfStudy = "UpdatedFOS"
            };

            userValidateDto = new UserValidateDto
            {
                Id        = userCompany.Id,
                Validated = true
            };

            pwDto = new ChangePasswordDto
            {
                OldPassword = userStudent.PasswordHash,
                NewPassword = "******"
            };

            companyUpdate = new CompanyUpdate
            {
                CompanyName = "Updated"
            };

            _context.Add(company);

            _context.Add(userCompany);
            _context.Roles.Add(roleCompany);
            _context.UserRoles.Add(new Microsoft.AspNetCore.Identity.IdentityUserRole <Guid>
            {
                RoleId = roleCompany.Id,
                UserId = userCompany.Id
            });
            _context.Add(userTeacher);
            _context.Roles.Add(roleTeacher);
            _context.UserRoles.Add(new Microsoft.AspNetCore.Identity.IdentityUserRole <Guid>
            {
                RoleId = roleTeacher.Id,
                UserId = userTeacher.Id
            });
            _context.Add(userStudent);
            _context.Roles.Add(roleStudent);
            _context.UserRoles.Add(new Microsoft.AspNetCore.Identity.IdentityUserRole <Guid>
            {
                RoleId = roleStudent.Id,
                UserId = userStudent.Id
            });
            _context.Add(internship);
            _context.SaveChanges();
        }
 public UserService(InternshipContext context)
 {
     _context = context;
     _hasher  = new PasswordHasher <User>();
 }
 public GemeenteRepository(InternshipContext context)
 {
     this.context = context;
     gemeentes = context.Gemeentes;
 }
 public DistrictController(InternshipContext context)
 {
     _context = context;
 }
Beispiel #22
0
 public PersonHospitalRelationshipController(InternshipContext context)
 {
     _context = context;
 }
Beispiel #23
0
 public UserTests()
 {
     InternshipContext.SetConnectionString("Server=(localdb)\\mssqllocaldb;Database=Internship_v2;Trusted_Connection=True;");
 }