예제 #1
0
        private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TeacherAccount teacherAccount = new TeacherAccount();

            teacherAccount.MdiParent = this;
            teacherAccount.Show();
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool check = ValidateForm();

            if (check == true)
            {
                string  role        = StatusList.GetItemText(StatusList.SelectedItem);
                string  name        = NameTbx.Text;
                string  email       = EmailTb.Text;
                string  password    = PasswordTbx.Text;
                string  phoneNumber = PhoneTbx.Text;
                string  address     = AddressTbx.Text;
                string  text        = "";
                Contact contact     = new Contact();

                if (role.Equals("CLIENT"))
                {
                    CustomerAccount client = new CustomerAccount();
                    int             group  = Int32.Parse(textBox1.Text);

                    text = client.addNewClient(name, password, group, email, phoneNumber, address);
                }
                else
                {
                    TeacherAccount staff = new TeacherAccount();
                    text = staff.addNewStaff(name, password, role, email, address, phoneNumber);
                }

                MessageBox.Show(text);
            }
        }
예제 #3
0
        public async Task <IActionResult> RegisterAction(RegisterModel registerModel)
        {
            if (ModelState.IsValid)
            {
                IdentityResult  result;
                UserAccount     user;
                UserAccountType accountType = registerModel.AccountType == "teacher" ? UserAccountType.TeacherAccount : UserAccountType.ParentAccount;

                var pH = new PasswordHasher <UserAccount>();

                if (accountType == UserAccountType.TeacherAccount)
                {
                    if (_schoolClasses.GetById(registerModel.TeacherSchoolClassId) == null)
                    {
                        return(RedirectToAction("Error", "Home"));
                    }

                    var newTeacher = new TeacherAccount
                    {
                        UserName = registerModel.RegisterLogin, /*ALSO KNOWN AS EMAIL */
                        Email    = registerModel.RegisterLogin,
                        Name     = registerModel.FirstName,
                        LastName = registerModel.LastName,
                    };

                    newTeacher.PasswordHash = pH.HashPassword(newTeacher, registerModel.RegisterPassword);
                    _schoolClasses.GetById(registerModel.TeacherSchoolClassId).TeacherAccount = newTeacher;
                    result = await _userManager.CreateAsync(newTeacher);

                    user = (UserAccount)newTeacher;
                }
                else
                {
                    var newParent = new ParentAccount()
                    {
                        UserName     = registerModel.RegisterLogin, /*ALSO KNOWN AS EMAIL */
                        Email        = registerModel.RegisterLogin,
                        Name         = registerModel.FirstName,
                        LastName     = registerModel.LastName,
                        PasswordHash = registerModel.RegisterPassword
                    };

                    newParent.PasswordHash = pH.HashPassword(newParent, registerModel.RegisterPassword);
                    result = await _userManager.CreateAsync(newParent);

                    user = (UserAccount)newParent;
                }

                if (result.Succeeded)
                {
                    await _signInManager.SignInAsync(user, true);

                    return(RedirectToAction("Success"));
                }
            }

            return(RedirectToAction("Error", "Home"));
        }
예제 #4
0
        public TeacherPage(TeacherAccount loginAccount)
        {
            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            LoggedInAccount       = loginAccount;
            cbx_NewTestDefinitionSubject.ItemsSource = Repository <Subject> .Instance.GetAll();

            UpdateCreatedTestDefinitionsListView();
            UpdateSentTestDefinitionListView();
        }
예제 #5
0
        private void ChangeBtn_Click(object sender, EventArgs e)
        {
            TeacherAccount staff     = new TeacherAccount();
            string         staffName = listOfStaff.GetItemText(listOfStaff.SelectedItem);

            string email  = EmailTbx.Text;
            string phone  = PhoneTbx.Text;
            string status = StatusList.GetItemText(StatusList.SelectedItem);
            string text   = staff.changePermission(staffName, status, email, phone);
        }
 private void toolStripAccount_Click(object sender, EventArgs e)
 {
     if (CheckOpened("TeacherAccount"))
     {
         Application.OpenForms["TeacherAccount"].BringToFront();
     }
     else
     {
         TeacherAccount frm = new TeacherAccount();
         frm.Show();
     }
 }
예제 #7
0
 public static bool CreateTestDefinition(string title, Subject subject, TeacherAccount teacherAccount)
 {
     if (IsTestDefinitionTitleValid(title))
     {
         return(Repository <TestDefinition> .Instance.Add(new TestDefinition {
             Title = title,
             SubjectId = subject.Id,
             TeacherAccountId = teacherAccount.Id
         }));
     }
     return(false);
 }
        public async Task <TeacherAccount> RegisterNewTeachersAsync(TeacherAccountDTO newTeacherAccount)
        {
            TeacherAccount teacher = new TeacherAccount
            {
                Id = System.Guid.NewGuid(),
                TeacherAccountName = newTeacherAccount.TeacherAccountName,
                Password           = newTeacherAccount.ConfirmPassword,
                TeacherFullName    = newTeacherAccount.TeacherFullName
            };
            await teachersAccountRepository.Create(teacher);

            return(teacher);
        }
예제 #9
0
 public IActionResult EditTeacherAccount(TeacherAccount fa)
 {
     if (ModelState.IsValid)
     {
         TeacherAccount t = new TeacherAccount();
         t.AccNo       = fa.AccNo;
         t.TeacherName = fa.TeacherName;
         t.BasicSalary = fa.BasicSalary;
         t.Month       = fa.Month;
         t.Year        = fa.Year;
         db.TeacherAccount.Update(t);
         db.SaveChanges();
     }
     return(RedirectToAction("ViewTeacherAccountList"));
 }
예제 #10
0
        public IActionResult ViewTeacherAccountList()
        {
            var acc = db.TeacherAccount;
            var i   = new List <TeacherAccount>();

            foreach (var f in acc)
            {
                TeacherAccount t = new TeacherAccount();
                t.AccNo       = f.AccNo;
                t.TeacherName = f.TeacherName;
                t.BasicSalary = f.BasicSalary;
                t.Month       = f.Month;
                t.Year        = f.Year;
                i.Add(t);
            }
            return(View(i));
        }
예제 #11
0
 public IActionResult CreateTeacherAccount(TeacherAccount fa)
 {
     if (ModelState.IsValid)
     {
         TeacherAccount t = new TeacherAccount();
         t.AccNo        = fa.AccNo;
         t.TeacherName  = fa.TeacherName;
         t.TeacherType  = fa.TeacherType;
         t.TeacherGread = fa.TeacherGread;
         t.BasicSalary  = fa.BasicSalary;
         t.Month        = fa.Month;
         t.Year         = fa.Year;
         db.TeacherAccount.Add(t);
         db.SaveChanges();
     }
     return(Redirect("ViewTeacherAccountList"));
 }
예제 #12
0
        // вход в аккаунт
        private void SIbtn_Click(object sender, EventArgs e)
        {
            string          email         = EmailTbx.Text;
            string          password      = PasswordTbx.Text;
            CustomerAccount client        = new CustomerAccount();
            bool            presentClient = client.checkClient(email, password);

            if (presentClient == true)
            {
                Form frm = new UserForm();
                frm.Show();
                this.Close();
            }
            else
            {
                TeacherAccount staff = new TeacherAccount();
                string         role  = staff.getRole(email, password);
                if (role.Equals("TEACHER                                           "))
                {
                    Program.Context.MainForm = new UserForm();

                    this.Close();

                    // покажет вторую форму и оставит приложение живым до ее закрытия
                    Program.Context.MainForm.Show();
                }
                else if (role.Equals("ADMIN                                             "))
                {
                    Program.Context.MainForm = new AdminForm();

                    this.Close();

                    // покажет вторую форму и оставит приложение живым до ее закрытия
                    Program.Context.MainForm.Show();
                }
                else if (role.Equals("MANAGER                                           "))
                {
                    Program.Context.MainForm = new ManagerForm();

                    this.Close();

                    // покажет вторую форму и оставит приложение живым до ее закрытия
                    Program.Context.MainForm.Show();
                }
            }
        }
예제 #13
0
 public IActionResult CreateTeacherAccount(TeacherAccount fa)
 {
     if (ModelState.IsValid)
     {
         TeacherAccount t = new TeacherAccount();
         t.AccNo       = fa.AccNo;
         t.TeacherName = fa.TeacherName;
         t.BasicSalary = fa.BasicSalary;
         t.Month       = fa.Month;
         t.Year        = fa.Year;
         db.TeacherAccount.Add(t);
         db.SaveChanges();
         ViewBag.Success = "New Teacher Account Created Successfully.";
         ModelState.Clear();
     }
     return(View());
     //return Redirect("ViewTeacherAccountList");
 }
예제 #14
0
        public async Task <IActionResult> CreateNewUserAccountAsync([FromBody] TeacherAccountDTO newTeacherAccount)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                TeacherAccount teacher = await teacherAccountService.RegisterNewTeachersAsync(newTeacherAccount);

                var uri = new Uri($"{Request.GetDisplayUrl()}/{teacher.Id}");

                return(Created(uri, teacher));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex));
            }
        }
예제 #15
0
        public void GetteacherIdTest()
        {
            string connStr = @"Data Source=DESKTOP-SDGK59R\SQLEXPRESS;
                            Initial Catalog=dance_school;
                            
                            Integrated Security=True";

            using (TransactionScope ts = new TransactionScope())
            {
                using (SqlConnection connection =
                           new SqlConnection(connStr))
                {
                    connection.Open();
                    TeacherAccount teacher = new TeacherAccount();

                    List <string> list = teacher.getTeacherName();


                    Assert.AreEqual(2, list.Count);
                }
            }
        }
예제 #16
0
 public async Task Create(TeacherAccount teacherAccount)
 {
     context.TeacherAccounts.Add(teacherAccount);
     context.SaveChanges();
 }
예제 #17
0
 public void Add(TeacherAccount newTeacher)
 {
     context.Add(newTeacher);
     context.SaveChanges();
 }
예제 #18
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddScoped <IUsersRepository, UsersRepository>();
            services.AddScoped <ITeachersAccountRepository, TeachersAccountRepository>();

            services.AddScoped <IUsersServices, UsersService>();
            services.AddScoped <ITeachersAccountService, TeacherAccountService>();

            services.AddDbContext <AppDbContext>();


            AppDbContext    dbContext      = new AppDbContext();
            IAuthentication authentication = new AuthenticationHandler(dbContext);

            services.AddAuthorization(options =>
            {
                options.AddPolicy("Admin", policy =>
                                  policy.RequireAssertion(async context =>
                {
                    String receive = ((AuthorizationFilterContext)(context.Resource)).HttpContext.Request.Headers["Authorization"];

                    if (receive != null)
                    {
                        string[] words        = receive.Split(' ');
                        TeacherAccount result = await authentication.FindTeacherAccount(words[0], words[1]);
                        return(result != null);
                    }
                    else
                    {
                        return(false);
                    }
                }));
            });

            services.AddAuthorization(options =>
            {
                options.AddPolicy("User", async policy =>
                                  policy.RequireAssertion(async context =>
                {
                    String receive = ((AuthorizationFilterContext)(context.Resource)).HttpContext.Request.Headers["Authorization"];

                    if (receive != null)
                    {
                        string[] words = receive.Split(' ');

                        TeacherAccount result = await authentication.FindTeacherAccount(words[0], words[1]);
                        User resultUser       = await authentication.FindUserAccount(words[0], words[1]);
                        if (result != null || resultUser != null)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }));
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }
예제 #19
0
        private static void Seed()
        {
            //Create Users
            var stud1 = new StudentAccount {
                Name = "Student1", Email = "Student1", Password = "******", TestForms = new List <TestForm>()
            };
            var stud2 = new StudentAccount {
                Name = "Student2", Email = "Student2", Password = "******", TestForms = new List <TestForm>()
            };
            var stud3 = new StudentAccount {
                Name = "Student3", Email = "", Password = "******", TestForms = new List <TestForm>()
            };
            var admin1 = new AdminAccount {
                Name = "Admin1", Email = "Admin1", Password = "******",
            };
            var admin2 = new AdminAccount {
                Name = "Admin2", Email = "Admin2", Password = "******",
            };
            var admin3 = new AdminAccount {
                Name = "Admin3", Email = "Admin3", Password = "******", IsNotRemoved = false
            };
            var teacher1 = new TeacherAccount {
                Name = "Teacher1", Email = "Teacher1", Password = "******", TestDefinitions = new List <TestDefinition>()
            };
            var teacher2 = new TeacherAccount {
                Name = "Teacher2", Email = "Teacher2", Password = "******", TestDefinitions = new List <TestDefinition>()
            };
            var teacher3 = new TeacherAccount {
                Name = "Teacher3", Email = "Teacher3", Password = "******", TestDefinitions = new List <TestDefinition>(), IsNotRemoved = true
            };

            //Create Subject
            var sub1 = new Subject {
                Name = "Initial"
            };
            var sub2 = new Subject {
                Name = "SystemUtveckling"
            };
            var sub3 = new Subject {
                Name = "Naturvetenskap"
            };
            var sub4 = new Subject {
                Name = "Litteratur"
            };

            //Create TestDefinition
            var test1 = new TestDefinition {
                Title = "DatabasProv", Subject = sub2, Paragraph = "1", TestDefinitionState = TestDefinitionState.Created, Questions = new List <Question>()
            };
            var test2 = new TestDefinition {
                Title = "MatteprovProv", Subject = sub3, Paragraph = "1", TestDefinitionState = TestDefinitionState.Sent, Questions = new List <Question>()
            };
            var test3 = new TestDefinition {
                Title = "FysikProv", Subject = sub3, Paragraph = "1", TestDefinitionState = TestDefinitionState.Created, Questions = new List <Question>()
            };
            var test4 = new TestDefinition {
                Title = "SvenskaProv", Subject = sub4, Paragraph = "1", TestDefinitionState = TestDefinitionState.Sent, Questions = new List <Question>()
            };
            var test5 = new TestDefinition {
                Title = "ProgrammeringsProv", Subject = sub2, Paragraph = "1", TestDefinitionState = TestDefinitionState.Created, Questions = new List <Question>()
            };
            var test6 = new TestDefinition {
                Title = "TestProv", Subject = sub1, Paragraph = "1", TestDefinitionState = TestDefinitionState.Created, Questions = new List <Question>()
            };

            //Create TestForms

            var testForms1 = new TestForm {
                TimeLimit = 1, FinalDate = new DateTime(2016, 10, 01), TestDefinition = test1
            };
            var testForms2 = new TestForm {
                TimeLimit = 30, FinalDate = new DateTime(2016, 08, 01), TestDefinition = test1
            };
            var testForms3 = new TestForm {
                TimeLimit = 30, FinalDate = new DateTime(2016, 08, 01), TestDefinition = test2
            };
            var testForms4 = new TestForm {
                TimeLimit = 30, FinalDate = new DateTime(2016, 08, 01), TestDefinition = test2
            };
            var testForms5 = new TestForm {
                TimeLimit = 30, FinalDate = new DateTime(2016, 08, 01), TestDefinition = test3
            };
            var testForms6 = new TestForm {
                TimeLimit = 30, FinalDate = new DateTime(2016, 08, 01), TestDefinition = test3
            };
            var testForms7 = new TestForm {
                TimeLimit = 30, FinalDate = new DateTime(2016, 08, 01), TestDefinition = test4
            };
            var testForms8 = new TestForm {
                TimeLimit = 30, FinalDate = new DateTime(2016, 08, 01), TestDefinition = test4
            };
            var testForms9 = new TestForm {
                TimeLimit = 30, FinalDate = new DateTime(2016, 08, 01), TestDefinition = test5
            };
            var testForms10 = new TestForm {
                TimeLimit = 30, FinalDate = new DateTime(2016, 08, 01), TestDefinition = test5
            };
            var testForms11 = new TestForm {
                TimeLimit = 30, FinalDate = new DateTime(2016, 08, 01), TestDefinition = test6
            };
            var testForms12 = new TestForm {
                TimeLimit = 30, FinalDate = new DateTime(2016, 08, 01), TestDefinition = test6
            };

            //Create Questions
            var question1 = new Question {
                QuestionType = QuestionType.Single, Text = "Vad är default för Primary Key?", Score = 5, Answers = new List <Answer>(), TestDefinition = test1
            };
            var question2 = new Question {
                QuestionType = QuestionType.Single, Text = "MY TEAM?", Score = 4, Answers = new List <Answer>(), TestDefinition = test2
            };
            var question3 = new Question {
                QuestionType = QuestionType.Multi, Text = "På vilka av nedan sätt kan man använda Entity Framewok?", Score = 3, Answers = new List <Answer>(), TestDefinition = test1
            };
            var question4 = new Question {
                QuestionType = QuestionType.Multi, Text = "1", Score = 2, Answers = new List <Answer>(), TestDefinition = test2
            };
            var question7 = new Question {
                QuestionType = QuestionType.Open, Text = "Vad heter det man skriver för att hämta data ur SQL databas?", Score = 3, Answers = new List <Answer>(), TestDefinition = test1
            };
            var question8 = new Question {
                QuestionType = QuestionType.Open, Text = "1", Score = 4, Answers = new List <Answer>(), TestDefinition = test2
            };

            var question9 = new Question {
                QuestionType = QuestionType.Single, Text = "Katt?", Score = 5, Answers = new List <Answer>(), TestDefinition = test3
            };
            var question10 = new Question {
                QuestionType = QuestionType.Single, Text = "Hello?", Score = 4, Answers = new List <Answer>(), TestDefinition = test4
            };
            var question11 = new Question {
                QuestionType = QuestionType.Multi, Text = "1", Score = 3, Answers = new List <Answer>(), TestDefinition = test3
            };
            var question12 = new Question {
                QuestionType = QuestionType.Multi, Text = "1", Score = 2, Answers = new List <Answer>(), TestDefinition = test4
            };
            var question15 = new Question {
                QuestionType = QuestionType.Open, Text = "1", Score = 3, Answers = new List <Answer>(), TestDefinition = test3
            };
            var question16 = new Question {
                QuestionType = QuestionType.Open, Text = "1", Score = 4, Answers = new List <Answer>(), TestDefinition = test4
            };

            var question17 = new Question {
                QuestionType = QuestionType.Single, Text = "Jag är en fråga", Score = 5, Answers = new List <Answer>(), TestDefinition = test5
            };
            var question18 = new Question {
                QuestionType = QuestionType.Single, Text = "??", Score = 4, Answers = new List <Answer>(), TestDefinition = test6
            };
            var question19 = new Question {
                QuestionType = QuestionType.Multi, Text = "1", Score = 3, Answers = new List <Answer>(), TestDefinition = test5
            };
            var question20 = new Question {
                QuestionType = QuestionType.Multi, Text = "1", Score = 2, Answers = new List <Answer>(), TestDefinition = test6
            };
            var question23 = new Question {
                QuestionType = QuestionType.Open, Text = "1", Score = 3, Answers = new List <Answer>(), TestDefinition = test5
            };
            var question24 = new Question {
                QuestionType = QuestionType.Open, Text = "1", Score = 4, Answers = new List <Answer>(), TestDefinition = test6
            };


            var question25 = new Question {
                QuestionType = QuestionType.Single, Text = "Vilket alternativ är en int?", Score = 4, Answers = new List <Answer>(), TestDefinition = test1
            };
            var question26 = new Question {
                QuestionType = QuestionType.Multi, Text = "Vilka datatyper kan sparas i en SQL databas?", Score = 6, Answers = new List <Answer>(), TestDefinition = test1
            };
            var question27 = new Question {
                QuestionType = QuestionType.Open, Text = "Vad står SQL för?", Score = 3, Answers = new List <Answer>(), TestDefinition = test1
            };
            var question28 = new Question {
                QuestionType = QuestionType.Single, Text = "SQL är ett?", Score = 2, Answers = new List <Answer>(), TestDefinition = test1
            };



            question25.Answers.Add(new Answer {
                Text = "5", CheckedOrRanked = 1
            });
            question25.Answers.Add(new Answer {
                Text = "Namn", CheckedOrRanked = 0
            });
            question25.Answers.Add(new Answer {
                Text = "&", CheckedOrRanked = 0
            });

            question26.Answers.Add(new Answer {
                Text = "Int", CheckedOrRanked = 1
            });
            question26.Answers.Add(new Answer {
                Text = "String", CheckedOrRanked = 1
            });
            question26.Answers.Add(new Answer {
                Text = "Åsnor", CheckedOrRanked = 0
            });

            question27.Answers.Add(new Answer {
                Text = "Structured-Query-Language", CheckedOrRanked = 1
            });

            question28.Answers.Add(new Answer {
                Text = "DBMS", CheckedOrRanked = 1
            });
            question28.Answers.Add(new Answer {
                Text = "Operativsystem", CheckedOrRanked = 0
            });
            question28.Answers.Add(new Answer {
                Text = "Efternamn", CheckedOrRanked = 0
            });


            //Create Student Question and Answer

            //Single
            question1.Answers.Add(new Answer {
                Text = "Id", CheckedOrRanked = 1
            });
            question1.Answers.Add(new Answer {
                Text = "Namn", CheckedOrRanked = 0
            });
            question1.Answers.Add(new Answer {
                Text = "Ålder", CheckedOrRanked = 0
            });

            question2.Answers.Add(new Answer {
                Text = "4", CheckedOrRanked = 0
            });
            question2.Answers.Add(new Answer {
                Text = "5", CheckedOrRanked = 1
            });
            question2.Answers.Add(new Answer {
                Text = "6", CheckedOrRanked = 0
            });

            question9.Answers.Add(new Answer {
                Text = "7", CheckedOrRanked = 0
            });
            question9.Answers.Add(new Answer {
                Text = "8", CheckedOrRanked = 0
            });
            question9.Answers.Add(new Answer {
                Text = "9", CheckedOrRanked = 1
            });

            question10.Answers.Add(new Answer {
                Text = "10", CheckedOrRanked = 1
            });
            question10.Answers.Add(new Answer {
                Text = "11", CheckedOrRanked = 0
            });
            question10.Answers.Add(new Answer {
                Text = "12", CheckedOrRanked = 0
            });

            question17.Answers.Add(new Answer {
                Text = "13", CheckedOrRanked = 0
            });
            question17.Answers.Add(new Answer {
                Text = "14", CheckedOrRanked = 1
            });
            question17.Answers.Add(new Answer {
                Text = "15", CheckedOrRanked = 0
            });

            question18.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 0
            });
            question18.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 0
            });
            question18.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 1
            });

            //Multi
            question3.Answers.Add(new Answer {
                Text = "Code First", CheckedOrRanked = 1
            });
            question3.Answers.Add(new Answer {
                Text = "Try First", CheckedOrRanked = 0
            });
            question3.Answers.Add(new Answer {
                Text = "Model First", CheckedOrRanked = 1
            });
            question3.Answers.Add(new Answer {
                Text = "Mine First", CheckedOrRanked = 0
            });
            question3.Answers.Add(new Answer {
                Text = "First First", CheckedOrRanked = 0
            });

            question4.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 1
            });
            question4.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 0
            });
            question4.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 1
            });

            question11.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 0
            });
            question11.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 1
            });
            question11.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 1
            });

            question12.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 1
            });
            question12.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 0
            });
            question12.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 1
            });

            question19.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 1
            });
            question19.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 1
            });
            question19.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 0
            });

            question20.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 0
            });
            question20.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 1
            });
            question20.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 1
            });

            //Ranked

            question4.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 1
            });
            question4.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 2
            });
            question4.Answers.Add(new Answer {
                Text = "1", CheckedOrRanked = 3
            });



            //Single



            question7.Answers.Add(new Answer {
                Text = "Fråga", CheckedOrRanked = 1
            });
            question8.Answers.Add(new Answer {
                Text = "hejsan", CheckedOrRanked = 1
            });
            question15.Answers.Add(new Answer {
                Text = "hej", CheckedOrRanked = 1
            });
            question16.Answers.Add(new Answer {
                Text = "hej", CheckedOrRanked = 1
            });
            question23.Answers.Add(new Answer {
                Text = "hej", CheckedOrRanked = 1
            });
            question24.Answers.Add(new Answer {
                Text = "hej", CheckedOrRanked = 1
            });

            //Add questions to Test Definitions

            test1.Questions.Add(question1);
            test1.Questions.Add(question3);
            test1.Questions.Add(question7);
            test1.Questions.Add(question25);
            test1.Questions.Add(question26);
            test1.Questions.Add(question27);
            test1.Questions.Add(question28);

            test2.Questions.Add(question2);
            test2.Questions.Add(question4);
            test2.Questions.Add(question8);

            test3.Questions.Add(question9);
            test3.Questions.Add(question11);
            test3.Questions.Add(question15);

            test4.Questions.Add(question10);
            test4.Questions.Add(question12);
            test4.Questions.Add(question16);

            test5.Questions.Add(question17);
            test5.Questions.Add(question19);
            test5.Questions.Add(question23);

            test6.Questions.Add(question18);
            test6.Questions.Add(question20);
            test6.Questions.Add(question24);

            //Add Answers to Questions


            //Add Tests to Users
            teacher1.TestDefinitions.Add(test1);
            teacher1.TestDefinitions.Add(test2);
            teacher3.TestDefinitions.Add(test6);
            teacher2.TestDefinitions.Add(test3);
            teacher2.TestDefinitions.Add(test4);
            teacher3.TestDefinitions.Add(test5);

            stud1.TestForms.Add(testForms1);
            stud2.TestForms.Add(testForms2);
            stud1.TestForms.Add(testForms3);
            stud2.TestForms.Add(testForms4);
            stud1.TestForms.Add(testForms5);
            stud2.TestForms.Add(testForms6);
            stud1.TestForms.Add(testForms7);
            stud2.TestForms.Add(testForms8);
            stud1.TestForms.Add(testForms9);
            stud2.TestForms.Add(testForms10);
            stud3.TestForms.Add(testForms11);
            stud3.TestForms.Add(testForms12);

            var list = new List <TestDefinition> {
                test1, test2, test3, test4, test5, test6
            };
            int local = 0;

            foreach (var test in list)
            {
                foreach (var question in test.Questions)
                {
                    local += question.Score;
                }
                test.MaxScore = local;
                local         = 0;
            }

            //Add to Database
            using (var db = new TestverktygContext())
            {
                //Add TestDefinitions
                db.TestDefinitions.Add(test1);
                db.TestDefinitions.Add(test2);
                db.TestDefinitions.Add(test3);
                db.TestDefinitions.Add(test4);
                db.TestDefinitions.Add(test5);
                db.TestDefinitions.Add(test6);


                //Add TestForms
                db.TestForms.Add(testForms1);
                db.TestForms.Add(testForms2);
                db.TestForms.Add(testForms3);
                db.TestForms.Add(testForms4);
                db.TestForms.Add(testForms5);
                db.TestForms.Add(testForms6);
                db.TestForms.Add(testForms7);
                db.TestForms.Add(testForms8);
                db.TestForms.Add(testForms9);
                db.TestForms.Add(testForms10);
                db.TestForms.Add(testForms11);
                db.TestForms.Add(testForms12);

                //Add Users
                db.StudentAccounts.Add(stud1);
                db.StudentAccounts.Add(stud2);
                db.StudentAccounts.Add(stud3);
                db.TeacherAccounts.Add(teacher1);
                db.TeacherAccounts.Add(teacher2);
                db.TeacherAccounts.Add(teacher3);
                db.AdminAccounts.Add(admin1);
                db.AdminAccounts.Add(admin2);
                db.AdminAccounts.Add(admin3);
                db.SaveChanges();
            }
        }