void createUser(string name, string email, string password, string role, StudentGroup group = null)
        {
            var user = new ApplicationUser
            {
                UserName = email,
                Name = name,
                Password = password,
                Email = email,
                LastVisition = DateTime.Now,
                RegistrationDate = DateTime.Now,
                UserInfo = "user",
                BlockDate = DateTime.Now,
                IsBlocked = true,
                BlockReason = ""
            };
            
            UserManager.Create(user, password);

            UserManager.AddToRole(user.Id, role);

            if (group!=null)
            {
                var thisUser = db.Users.First(x => x.Id == user.Id);

                // var group = groups[r.Next(groups.Count())%groups.Count()];

                thisUser.StudentGroup = group;
                thisUser.StudentGroupId = group.Id;

                db.Entry(thisUser).State = EntityState.Modified;
                db.Entry( group ).State = EntityState.Modified;

            }
        }
        public ActionResult StartIfAdmin()
        {
            if (db.Users.Count() == 1)
            {

                var studentsGroup09209 = new StudentGroup
                {
                    Name = "09-209",
                    Students = new List<ApplicationUser>()
                };

                var studentsGroup09208 = new StudentGroup
                {
                    Name = "09-208",
                    Students = new List<ApplicationUser>()
                };

                var studentsGroup09207 = new StudentGroup
                {
                    Name = "09-207",
                    Students = new List<ApplicationUser>()
                };


                db.StudentsGroups.Add(studentsGroup09207);
                db.StudentsGroups.Add(studentsGroup09208);
                db.StudentsGroups.Add(studentsGroup09209);

                db.SaveChanges();
                
                db.MathTaskTypes.Add(new MathTaskType
                {
                    Name = "Однозначность кодирования"
                });
                db.MathTaskTypes.Add(new MathTaskType
                {
                    Name = "Построение префиксного кода"
                });
                db.MathTaskTypes.Add(new MathTaskType
                {
                    Name = "Однозначность декодирования"
                });
                db.MathTaskTypes.Add(new MathTaskType
                {
                    Name = "Оптимальный код Хаффмана"
                });         
                db.MathTaskTypes.Add(new MathTaskType
                {
                    Name = "Нахождение ошибки в коде Хемминга",
                });
                db.MathTaskTypes.Add(new MathTaskType
                {
                    Name = "Анализ булевой функции"
                });

                db.SaveChanges();
                
                createUser("Виктор Васильевич", "*****@*****.**", "123qwe123qwe", "Teacher");
                createUser("Елена Геннадьевна", "*****@*****.**", "123qwe123qwe", "Teacher");
                createUser("Мельникова Валерия", "*****@*****.**", "123qwe123qwe", "Student", studentsGroup09207);
                createUser("Миллер Кристина", "*****@*****.**", "123qwe123qwe", "Student", studentsGroup09207);
                createUser("Водолазов Артем", "*****@*****.**", "123qwe123qwe", "Student", studentsGroup09207);
                createUser("Лаптев Евгений", "*****@*****.**", "123qwe123qwe", "Student", studentsGroup09207);
                createUser("Трегубов Сергей", "*****@*****.**", "123qwe123qwe", "Student", studentsGroup09207);
                createUser("Кусакина Яна", "*****@*****.**", "123qwe123qwe", "Student", studentsGroup09208);
                createUser("Хохлова Ирина", "*****@*****.**", "123qwe123qwe", "Student", studentsGroup09208);
                createUser("Лукашкин Максим", "*****@*****.**", "123qwe123qwe", "Student", studentsGroup09208);
                createUser("Жадаева Елена", "*****@*****.**", "123qwe123qwe", "Student", studentsGroup09208);
                createUser("Ненашева Анастасия", "*****@*****.**", "123qwe123qwe", "Student", studentsGroup09208);
                createUser("Глухова Алена", "*****@*****.**", "123qwe123qwe", "Student", studentsGroup09208);
                createUser("Морозов Дмитрий", "*****@*****.**", "123qwe123qwe", "Student", studentsGroup09208);
                createUser("Краснов Александр", "*****@*****.**", "123qwe123qwe", "Student", studentsGroup09208);
                createUser("Абдул Оглы", "*****@*****.**", "123qwe123qwe", "Student", studentsGroup09209);

                db.Entry(studentsGroup09208).State = EntityState.Modified;
                db.Entry(studentsGroup09207).State = EntityState.Modified;
                db.Entry(studentsGroup09209).State = EntityState.Modified;

                db.SaveChanges();
            }

            return RedirectToAction("Index", "Home");
        }