Department represents a single item(record) stored in Employees collection.
コード例 #1
0
        public void TestIfSchoolAddCorrectListOfCoursesOnSchoolCreation()
        {
            List<Course> courses = new List<Course>( ){new Course("math")};
            School school = new School("8-mo osnovno", courses);

            Assert.AreEqual(courses, school.Courses, string.Format("Expeted to receive first name of courses name math. Received {0}", courses[0].Name));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: damy90/Telerik-all
    static void Main()
    {
        //some tests
        Student go6o = new Student("Go6o", 1245);
        Student to6o = new Student("To6o", 2345);
        to6o.AddComment("YOU SHAL NOT PAAAAASSS!!!");
        to6o.AddComment("To be expelled");

        Discipline borringStuff = new Discipline("Borring Stuff", 100, 1);
        List<Discipline> profesorovDisciplines = new List<Discipline>()
        {
            borringStuff
        };
        Teacher profesorov = new Teacher("Profesorov", profesorovDisciplines);
        //create class
        List<Student> class1AStudents = new List<Student>()
        { 
            to6o, go6o
        };
        List<Teacher> class1ATeachers = new List<Teacher>()
        {
            profesorov
        };
        List<SchoolClass> TUClasses2 = new List<SchoolClass>()
        {
            new SchoolClass(class1AStudents, "Class 1-A", class1ATeachers)
        };
        School TU = new School(TUClasses2);
    }
コード例 #3
0
        public void TestRegistringAValidStudentNotToThrow()
        {
            var testStudent = new Student("Andy", 10000);
            var testSchool = new School("The Academy");

            testSchool.RegisterStudent(testStudent);
        }
コード例 #4
0
        public void TestIfSchoolNameIfSetCorrectlyAfterCourseCreation()
        {
            School school = new School("8-mo osnovno");
            school.Name = "PMG osnovno";

            Assert.AreEqual("PMG osnovno", school.Name, string.Format("Expected school name on school creation PMG osnovno. Received {0}", school.Name));
        }
コード例 #5
0
    public void Test_RegisterStudentReturnsCorrectStudent()
    {
        var school = new School();
        var student = school.RegisterStudent("pesho");

        Assert.AreEqual("pesho", student.Name);
    }
コード例 #6
0
        public void TestToAddCourse()
        {
            School telerik = new School("TelerikAcademy");
            telerik.SetOfCourses.Add(new Course("C#"));

            Assert.AreEqual(1, telerik.SetOfCourses.Count);
        }
コード例 #7
0
        public static void Main()
        {
            Student student1 = new Student("Aaaa Bbb", 1);
            Student student2 = new Student("Cccc Ddd", 2);
            Student student3 = new Student("Eeee Fff", 3, "ZZZZZZZZZZZZZ");

            Teacher teacher1 = new Teacher("Zzzz yyyy");
            Teacher teacher2 = new Teacher("Xxxx wwww");

            Discipline oop = new Discipline("oop", 12, 10, "AAAAAAAA");
            Discipline csharp = new Discipline("Csharp", 20, 14);
            Discipline java = new Discipline("Java", 15, 16);

            teacher1.AddDisicipline(oop);
            teacher1.AddDisicipline(csharp);
            teacher2.AddDisicipline(oop);
            teacher1.ListOfDisciplines.Add(java);
            School mySchool = new School();
            ClassInSchool myClass = new ClassInSchool("MyClassName");
            myClass.AddStudent(student1);
            myClass.AddStudent(student2);
            myClass.AddStudent(student3);
            myClass.RemoveStudent(student1);
            myClass.AddTeacher(teacher1);
            myClass.AddTeacher(teacher2);
            mySchool.AddClass(myClass);
            System.Console.WriteLine(myClass);
        }
コード例 #8
0
ファイル: School.Tests.cs プロジェクト: nzhul/TelerikAcademy
 public void School_AddCourseTest()
 {
     Course java = new Course("Java");
     School myTestSchool = new School();
     myTestSchool.AddCourse(java);
     Assert.AreEqual(java.CourseName, myTestSchool.Courses[0].CourseName);
 }
コード例 #9
0
        public void TestSchoolName()
        {
            School telerik = new School("TelerikAcademy");
            string expected = "TelerikAcademy";

            Assert.AreEqual(expected, telerik.Name);
        }
コード例 #10
0
ファイル: SchoolTests.cs プロジェクト: sabrie/TelerikAcademy
    public void TestAddDuplicateStudentId()
    {
        School school = new School();

        school.AddStudent(new Student("Pesho", 50000));
        school.AddStudent(new Student("Pesho", 50000));
    }
コード例 #11
0
 public void RemoveNonExistingCourseTest()
 {
     List<Course> courses = new List<Course>();
     School school = new School(courses);
     Course javaScript = new Course("JavaScript");
     school.RemoveCourse(javaScript);
 }
コード例 #12
0
ファイル: Demo.cs プロジェクト: niki-funky/Telerik_Academy
        private static void Main()
        {
            try
            {
                Student pesho = new Student("Pesho Georgiev");
                Student gosho = new Student("Gosho Ivanov");
                Student misho = new Student("Misho Cekov");
                Student sasho = new Student("Sasho Kostov");

                Course telerikAcademy = new Course("Telerik Academy");
                Course webProgramming = new Course("Web Programming");

                webProgramming.AddStudent(sasho);

                telerikAcademy.AddStudent(pesho);
                telerikAcademy.AddStudent(gosho);
                telerikAcademy.AddStudent(misho);

                telerikAcademy.RemoveStudent(gosho);
                Console.WriteLine(gosho.ToString() + " was removed from course.");

                Console.WriteLine("Courses:");
                Console.WriteLine(telerikAcademy);

                School freeSchool = new School("School of Computer Sciences");
                freeSchool.AddCourse(webProgramming);
                freeSchool.AddCourse(telerikAcademy);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #13
0
ファイル: SchoolTest.cs プロジェクト: KirilToshev/Projects
 static void Main()
 {
     //Student test
     //Console.WriteLine("Student test");
     List<Student> studentsList = new List<Student>();
     studentsList.Add(new Student("Vesi", 1231532));
     studentsList.Add(new Student("Natalia", 462346));
     studentsList.Add(new Student("Mitko", 0982374));
     //Console.WriteLine(studentsList.Print());
     //Teacher test
     //Console.WriteLine("Teacher test");
     List<Teacher> teachersList = new List<Teacher>();
     teachersList.Add(new Teacher("prof. Petrov"));
     teachersList.Add(new Teacher("doc. Hristov"));
     teachersList.Add(new Teacher("as. Doneva"));
     teachersList[0].AddDiscipline("Computer sciense", 4, 5);
     teachersList[0].AddDiscipline("Hardware basics", 3, 2);
     teachersList[1].AddDiscipline("C# Basics", 4, 4);
     teachersList[1].AddDiscipline("C# OOP", 5, 5);
     teachersList[2].AddDiscipline("Operating Systems", 3, 2);
     //Console.WriteLine(teachersList.Print());
     //Class test
     //Console.WriteLine("Class test");
     Class classA = new Class('A', teachersList, studentsList);
     //Console.WriteLine(classA.ToString());
     Class classB = new Class('B', teachersList, studentsList);
     classB.Comments = "This is class B";
     //School test
     Console.WriteLine("School test:");
     School TUES = new School();
     TUES.AddClass(classA);
     TUES.AddClass(classB);
     Console.WriteLine(TUES.ToString());
 }
コード例 #14
0
 public void SchoolShouldThrowExceptionWhenAddingExistingStudent()
 {
     var school = new School("Telerik Academy");
     var student = new Student("John", "Doe", 12345);
     school.AddStudent(student);
     school.AddStudent(student);
 }
コード例 #15
0
 public void SetValue_ForInt32_ChangesCurrentValue()
 {
     var propMetadata = modelForType.GetPropertyMetadata(typeof(School).GetProperty("Rating"));
     var inst = new School() { Rating = 7 };
     propMetadata.SetValue(inst, 8);
     Assert.AreEqual(8, inst.Rating);
 }
コード例 #16
0
 public void SchoolShouldAddCourseCorrectly()
 {
     var school = new School("Telerik Academy");
     var course = new Course("C#");
     school.AddCourse(course);
     Assert.AreSame(course, school.Courses.First());
 }
コード例 #17
0
 public void SchoolShouldAddStudentCorrectly()
 {
     var school = new School("Telerik Academy");
     var student = new Student("John", "Doe", 12345);
     school.AddStudent(student);
     Assert.AreSame(student, school.Students.First());
 }
コード例 #18
0
 public void AddingCourseThatAlreadyExistsShouldThrow()
 {
     School school = new School("Hogwards");
     Course course = new Course("BatCourse");
     school.AddCourse(course);
     school.AddCourse(course);
 }
コード例 #19
0
        public void AddingStudentShouldNotThrow()
        {
            School school = new School("Hogwards");
            Student student = new Student("Stamat", 10000);

            school.AddStudent(student);
        }
コード例 #20
0
ファイル: ShoolTests.cs プロジェクト: deskuuu/TelerikAcademy
 public void RemoveNullCourse_RemoveNullCourseFromShool_ShouldThrowArgumentNullException()
 {
     var school = new School("HR.Smirnenski");
     Course course = null;
     school.AddCourse(course);
     school.RemoveCourse(course);
 }
コード例 #21
0
        public void AddingCourseShouldNotThrow()
        {
            School school = new School("Hogwards");
            Course course = new Course("BatCourse");

            school.AddCourse(course);
        }
コード例 #22
0
ファイル: ShoolTests.cs プロジェクト: deskuuu/TelerikAcademy
 public void AddTheSameCourse_AddTheSameCourseInShool_ShouldThrowNullException()
 {
     var school = new School("HR.Smirnenski");
     var course = new Course();
     school.AddCourse(course);
     school.AddCourse(course);
 }
コード例 #23
0
 public void AddingNewStudentShouldWorkCorrectly()
 {
     var school = new School("Greendale");
     var student = new Student("Britta Perry", 10002);
     school.AddStudent(student);
     Assert.ReferenceEquals(student, school.Students.First());
 }
コード例 #24
0
 public void AddingExistingStudentShouldThrow()
 {
     var school = new School("Greendale");
     var studentOne = new Student("Peshkata", 10000);
     school.AddStudent(studentOne);
     school.AddStudent(studentOne);
 }
コード例 #25
0
 public void AddingNewCourseShouldWorkCorrectly()
 {
     var school = new School("Greendale");
     var course = new Course("Grifting");
     school.AddCourse(course);
     Assert.AreSame(course, school.Courses.First());
 }
コード例 #26
0
        static void Main()
        {
            Class firstClass = new Class("8b");
            School school = new School("My school");
            school.Classes.Add(firstClass);
            //Console.WriteLine(school.ToString());
            firstClass.FillWithStudents();

            Teacher Joreto = new Teacher("Joreto");
            Joreto.Disciplines.Add(new Discipline("Math", 1, 1));
            Joreto.Disciplines.Add(new Discipline("Physic", 2, 3));
            Joreto.Disciplines.Add(new Discipline("Drawing", 3, 3));

            Teacher Pesho = new Teacher("Pesho");
            Pesho.Disciplines.Add(new Discipline("Math", 1, 1));
            Pesho.Disciplines.Add(new Discipline("Physic", 2, 3));

            firstClass.Teachers.Add(Joreto);
            firstClass.Teachers.Add(Pesho);
            Console.WriteLine("Teacher");
            Console.WriteLine(firstClass.Teachers.ToString());

            Console.WriteLine(firstClass.ToString());
            Console.WriteLine("end of haha");
            Console.WriteLine(school.ToString());

            Console.WriteLine(school.Classes[0].Teachers[0].ToString());
        }
コード例 #27
0
 public void SchoolShouldThrowInvalidOperationExceptionWhenTryingToAddAStudentTwice()
 {
     var school = new School("Gosho school");
     var student = new Student("Gosho", 99999);
     school.AddStudent(student);
     school.AddStudent(student);
 }
コード例 #28
0
        public void School_Create_Exists()
        {

            var school = new School(TestSchoolName);

            Assert.AreEqual(TestSchoolName, school.Name, "School name doesn't exist. Something is wrong with School creation");
        }
コード例 #29
0
		public void RemoveCourse_ThrowsExceptionWhenParameterNull()
		{
			List<Course> courses = new List<Course>();
			School school = new School(courses);
			Course javascript = new Course("Javascript");
			school.RemoveCourse(javascript);
		}
コード例 #30
0
ファイル: ShoolTests.cs プロジェクト: deskuuu/TelerikAcademy
 public void AddTheSameStudent_AddTheSameStudentInShool_ShouldThrowNullException()
 {
     var school = new School("HR.Smirnenski");
     Student student = new Student("Anna MAriq", 9);
     school.AddStudent(student);
     school.AddStudent(student);
 }
コード例 #31
0
ファイル: SchoolService.cs プロジェクト: jssandoval/School502
 public async Task InsertSchool(School school)
 {
     //await _schoolRepository.Add(school);
     await _schoolRepository.SchoolRepository.Add(school);
 }
コード例 #32
0
        // GET api/School/5
        public IHttpActionResult GetSchool(int id)
        {
            School school = db.Schools.Where(s => s.SchoolID == id).FirstOrDefault();

            return(Json(school));
        }
コード例 #33
0
ファイル: CastInfo.cs プロジェクト: zerodowned/kaltar
 public CastInfo(Type type, School school)
 {
     m_SpellType = type;
     m_School    = school;
 }
コード例 #34
0
            protected override bool Allow(OccupationNames value)
            {
                School school = CareerManager.GetStaticCareer(value) as School;

                return(school != null);
            }
コード例 #35
0
 public GroupsModel(School injectedContext)
 {
     db = injectedContext;
 }
コード例 #36
0
        public static async void Initialize(IServiceProvider serviceProvider)
        {
            var context = serviceProvider.GetService <ApplicationDbContext>();

            context.Database.Migrate();
            if (!context.Roles.Any())
            {
                string[] roles = { "Eigenaar", "Schooladmin", "Leraar" };

                var roleStore = new RoleStore <IdentityRole>(context);
                foreach (string role in roles)
                {
                    IdentityRole identityRole = new IdentityRole {
                        Name = role, NormalizedName = role.ToUpper()
                    };
                    await roleStore.CreateAsync(identityRole);
                }
            }
            if (!context.Schools.Any())
            {
                School maSchool = new School
                {
                    Id        = Guid.NewGuid(),
                    Name      = "Ods Meester Aafjes",
                    Email     = "*****@*****.**",
                    PostCode  = "4194 RR Meteren",
                    Street    = "J.H. Lievense van Herwaardenstraat 2",
                    Telephone = "0345 581 158",
                    Url       = "http://odsmeesteraafjes.nl"
                };
                School oeSchool = new School
                {
                    Id        = Guid.NewGuid(),
                    Name      = "Obs Est",
                    Email     = "*****@*****.**",
                    PostCode  = "4185 NA EST",
                    Street    = "Dorpsstraat 3",
                    Telephone = "0345-569481",
                    Url       = "http://www.obsest.nl"
                };
                context.Schools.Add(maSchool);
                context.Schools.Add(oeSchool);
                context.SaveChanges();
            }
            var schools = context.Schools.ToList();

            if (!context.ApplicationUserGroups.Any())
            {
                string[] maGroups =
                {
                    "Groep 1/2a", "Groep 1/2b", "Groep 1/2c", "Groep 1/2d", "Groep 3a", "Groep 3b", "Groep 4a",
                    "Groep 4b",   "Groep 5a",   "Groep 5b",   "Groep 6a",   "Groep 6b", "Groep 7a", "Groep 7b","Groep 8a",
                    "Groep 8b",   "Directie"
                };
                string[] oeGroups =
                {
                    "Groep 1-2-3", "Groep 4-5-6", "Groep 7-8"
                };
                foreach (string group in maGroups)
                {
                    context.ApplicationUserGroups.Add(new ApplicationUserGroup {
                        GroupName = group, School = schools.First(s => s.Name == "Ods Meester Aafjes")
                    });
                    context.SaveChanges();
                }
                foreach (string group in oeGroups)
                {
                    context.ApplicationUserGroups.Add(new ApplicationUserGroup {
                        GroupName = group, School = schools.First(s => s.Name == "Obs Est")
                    });
                    context.SaveChanges();
                }
                context.SaveChanges();
            }
            if (!context.ConversationTypes.Any())
            {
                var con1 = new ConversationType
                {
                    ConversationDuration = 15,
                    ConversationName     = "Voortgangsgesprek",
                    School = schools.First(s => s.Name == "Ods Meester Aafjes")
                };
                var con2 = new ConversationType
                {
                    ConversationDuration = 10,
                    ConversationName     = "Rapportgesprek",
                    School = schools.First(s => s.Name == "Ods Meester Aafjes")
                };
                context.ConversationTypes.Add(con1);
                context.ConversationTypes.Add(con2);
                context.SaveChanges();
                var groupList1 = new List <ApplicationUserGroup>
                {
                    context.ApplicationUserGroups.First(g => g.Id == 5),
                    context.ApplicationUserGroups.First(g => g.Id == 2),
                    context.ApplicationUserGroups.First(g => g.Id == 7)
                };
                var groupList2 = new List <ApplicationUserGroup>
                {
                    context.ApplicationUserGroups.First(g => g.Id == 15),
                    context.ApplicationUserGroups.First(g => g.Id == 13),
                    context.ApplicationUserGroups.First(g => g.Id == 9),
                    context.ApplicationUserGroups.First(g => g.Id == 4)
                };
                foreach (var groupList in groupList1)
                {
                    context.ConversationTypeClaims.Add(new ConversationTypeClaim {
                        ConversationType = con1, Group = groupList
                    });
                }
                foreach (var groupList in groupList2)
                {
                    context.ConversationTypeClaims.Add(new ConversationTypeClaim {
                        ConversationType = con2, Group = groupList
                    });
                }
            }
            if (!context.ConversationPlanDates.Any())
            {
                DateTime[] startDates =
                {
                    new DateTime(2017, 5, 28),
                    new DateTime(2017, 6,  2),
                    new DateTime(2017, 6,  7),
                    new DateTime(2017, 6, 20)
                };
                DateTime[] endDates =
                {
                    new DateTime(2017, 6,  8),
                    new DateTime(2017, 6, 19),
                    new DateTime(2017, 6, 29),
                    new DateTime(2017, 7, 5)
                };
                var groupList = new List <List <ApplicationUserGroup> >();
                groupList.Add(new List <ApplicationUserGroup>
                {
                    context.ApplicationUserGroups.First(g => g.Id == 4),
                    context.ApplicationUserGroups.First(g => g.Id == 7)
                });
                groupList.Add(new List <ApplicationUserGroup>
                {
                    context.ApplicationUserGroups.First(g => g.Id == 5),
                    context.ApplicationUserGroups.First(g => g.Id == 2),
                    context.ApplicationUserGroups.First(g => g.Id == 7)
                });
                groupList.Add(new List <ApplicationUserGroup>
                {
                    context.ApplicationUserGroups.First(g => g.Id == 15),
                    context.ApplicationUserGroups.First(g => g.Id == 13),
                    context.ApplicationUserGroups.First(g => g.Id == 9),
                    context.ApplicationUserGroups.First(g => g.Id == 4)
                });
                groupList.Add(new List <ApplicationUserGroup>
                {
                    context.ApplicationUserGroups.First(g => g.Id == 9),
                    context.ApplicationUserGroups.First(g => g.Id == 8)
                });

                for (int i = 0; i < startDates.Length; i++)
                {
                    var planDate = new ConversationPlanDate
                    {
                        StartDate = startDates[i],
                        EndDate   = endDates[i],
                        School    = schools.First(s => s.Name == "Ods Meester Aafjes")
                    };
                    context.ConversationPlanDates.Add(planDate);
                    foreach (var group in groupList[i])
                    {
                        context.ConversationPlanDateClaims.Add(new ConversationPlanDateClaim
                        {
                            ConversationPlanDate = planDate,
                            Group = group
                        });
                    }
                }
            }
            if (!context.Users.Any())
            {
                var password  = new PasswordHasher <ApplicationUser>();
                var userStore = new UserStore <ApplicationUser>(context);
                UserManager <ApplicationUser> _userManager = serviceProvider.GetService <UserManager <ApplicationUser> >();
                string hashed;
                var    owner = new ApplicationUser
                {
                    Email         = "*****@*****.**",
                    UserName      = "******",
                    SecurityStamp = Guid.NewGuid().ToString("D")
                };
                owner.NormalizedEmail    = owner.Email.ToUpper();
                owner.NormalizedUserName = owner.UserName.ToUpper();
                hashed             = password.HashPassword(owner, "Dalton");
                owner.PasswordHash = hashed;
                await userStore.CreateAsync(owner);

                await _userManager.AddToRoleAsync(owner, "Eigenaar");


                var schoolAdminMA = new ApplicationUser
                {
                    Email         = "*****@*****.**",
                    UserName      = "******",
                    SecurityStamp = Guid.NewGuid().ToString("D"),
                    School        = schools.First(s => s.Name == "Ods Meester Aafjes")
                };
                schoolAdminMA.NormalizedEmail    = schoolAdminMA.Email.ToUpper();
                schoolAdminMA.NormalizedUserName = schoolAdminMA.UserName.ToUpper();
                hashed = password.HashPassword(schoolAdminMA, "Dalton");
                schoolAdminMA.PasswordHash = hashed;
                await userStore.CreateAsync(schoolAdminMA);

                await _userManager.AddToRoleAsync(schoolAdminMA, "Schooladmin");

                var schoolAdminOE = new ApplicationUser
                {
                    Email         = "*****@*****.**",
                    UserName      = "******",
                    SecurityStamp = Guid.NewGuid().ToString("D"),
                    School        = schools.First(s => s.Name == "Obs Est")
                };
                schoolAdminOE.NormalizedEmail    = schoolAdminOE.Email.ToUpper();
                schoolAdminOE.NormalizedUserName = schoolAdminOE.UserName.ToUpper();
                hashed = password.HashPassword(schoolAdminOE, "Dalton");
                schoolAdminOE.PasswordHash = hashed;
                await userStore.CreateAsync(schoolAdminOE);

                await _userManager.AddToRoleAsync(schoolAdminOE, "Schooladmin");

                var teacher = new ApplicationUser
                {
                    Email         = "*****@*****.**",
                    UserName      = "******",
                    SecurityStamp = Guid.NewGuid().ToString("D"),
                    Group         = context.ApplicationUserGroups.First(g => g.GroupName == "Groep 6b"),
                    School        = schools.First(s => s.Name == "Ods Meester Aafjes")
                };
                teacher.NormalizedEmail    = teacher.Email.ToUpper();
                teacher.NormalizedUserName = teacher.UserName.ToUpper();
                hashed = password.HashPassword(teacher, "Dalton");
                teacher.PasswordHash = hashed;
                await userStore.CreateAsync(teacher);

                await _userManager.AddToRoleAsync(teacher, "Leraar");
            }
            await context.SaveChangesAsync();
        }
コード例 #37
0
 public TeacherWrapperModel(User user, Teacher teacher, School okul)
 {
     this.user    = user;
     this.teacher = teacher;
     this.okul    = okul;
 }
コード例 #38
0
 public void Update(School school)
 {
     db.Entry(school).State = EntityState.Modified;
 }
コード例 #39
0
        public ActionResult Profile(tbl_schoolValidation sa)

        {
            School school = new School();

            try
            {
                //loginTable l = new loginTable();
                int userid = Convert.ToInt32((Session["school"]));

                var l = db.loginTables.FirstOrDefault(t => t.UserId == userid);

                if (ModelState.IsValid)
                {
                    if (sa != null)
                    {
                        if (l != null)
                        {
                            Session["schoolName"] = sa.School_Name;
                            l.UserId          = userid;
                            l.Name            = sa.School_Name;
                            l.Password        = sa.Password;
                            l.Email           = sa.School_Email;
                            l.RoleID          = 2;
                            db.Entry(l).State = EntityState.Modified;

                            db.SaveChanges();
                        }
                        string filename  = Path.GetFileNameWithoutExtension(sa.UserImageFIle.FileName);
                        string extension = Path.GetExtension(sa.UserImageFIle.FileName);
                        filename = DateTime.Now.ToString("yymmssff") + extension;



                        school.School_Image = "~/Content/img/users/" + filename;
                        school.School_Name  = sa.School_Name;
                        school.School_Email = sa.School_Email;
                        school.Password     = sa.Password;
                        school.School_Id    = userid;



                        if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png")
                        {
                            if (sa.UserImageFIle.ContentLength <= 1000000)
                            {
                                db.Entry(school).State = EntityState.Modified;



                                string oldImgPath = Request.MapPath(Session["imgPath"].ToString());

                                if (db.SaveChanges() > 0)
                                {
                                    filename = Path.Combine(Server.MapPath("~/Content/img/users/"), filename);
                                    sa.UserImageFIle.SaveAs(filename);
                                    if (System.IO.File.Exists(oldImgPath))
                                    {
                                        System.IO.File.Delete(oldImgPath);
                                    }


                                    ViewBag.Message = "Data Updated";
                                    return(RedirectToAction("Profile"));
                                }
                            }
                            else
                            {
                                ViewBag.msg = "File Size must be Equal or less than 1mb";
                            }
                        }
                        else
                        {
                            ViewBag.msg = "Inavlid File Type";
                        }
                    }

                    //}
                    else
                    {
                        school.School_Image = Session["imgPath"].ToString();
                        if (l != null)
                        {
                            Session["schoolName"] = sa.School_Name;
                            l.UserId          = userid;
                            l.Name            = sa.School_Name;
                            l.Password        = sa.Password;
                            l.Email           = sa.School_Email;
                            l.RoleID          = 2;
                            db.Entry(l).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                        school.School_Name     = sa.School_Name;
                        school.School_Email    = sa.School_Email;
                        school.Password        = sa.Password;
                        school.School_Id       = userid;
                        db.Entry(school).State = EntityState.Modified;

                        if (db.SaveChanges() > 0)
                        {
                            ViewBag.Message = "Data Updated";
                            return(RedirectToAction("Profile"));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Not Updated";
                return(View());
            }
            return(View());
        }
コード例 #40
0
        public void Delete(int id)
        {
            School school = db.Schools.Find(id);

            db.Schools.Remove(school);
        }
コード例 #41
0
 public bool UserOpinionExists(int userId, School school)
 => school != null?school.Opinions.Any(o => o.UserId == userId) : false;
コード例 #42
0
 public void Insert(School school)
 {
     db.Schools.Add(school);
 }
コード例 #43
0
 public SchoolModel(School model) : base(model)
 {
     LoadFromModel(model);
 }
コード例 #44
0
        public void School_ConstructorTest()
        {
            School myTestSchool = new School();

            Assert.IsNotNull(myTestSchool);
        }
コード例 #45
0
        public void TestSchool()
        {
            School academy = new School();

            Assert.AreEqual(this.RetutnInfo(0, 0), academy.ShowInformationAboutSchool());
        }
コード例 #46
0
        private void CreateData()
        {
            if (this._userData == null)
            {
                return;
            }
            User user = this._userData.user;

            if (!string.IsNullOrEmpty(this._userData.Activity) || this._userData.AdminLevel > 1)
            {
                this.InfoSections.Add(new ProfileInfoSectionItem()
                {
                    Items = new List <ProfileInfoItem>()
                    {
                        (ProfileInfoItem) new StatusItem((IProfileData)this._userData)
                    }
                });
            }
            List <ProfileInfoItem> profileInfoItemList1 = new List <ProfileInfoItem>();

            if (!string.IsNullOrEmpty(user.bdate))
            {
                profileInfoItemList1.Add((ProfileInfoItem) new BirthdayItem(this._userData));
            }
            if (!string.IsNullOrEmpty(user.home_town))
            {
                profileInfoItemList1.Add((ProfileInfoItem) new HomeTownItem(user.home_town));
            }
            Occupation occupation = user.occupation;

            if (occupation != null)
            {
                string str = occupation.name;
                if (occupation.type == OccupationType.university && user.universities != null)
                {
                    University university = (University)Enumerable.FirstOrDefault <University>(user.universities, (Func <University, bool>)(u => u.id == occupation.id));
                    if (university != null && university.graduation > 0)
                    {
                        str = string.Format("{0} '{1:00}", university.name, (university.graduation % 100));
                    }
                }
                else if (occupation.type == OccupationType.school && user.schools != null)
                {
                    List <School> .Enumerator enumerator = user.schools.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            School current = enumerator.Current;
                            long   result;
                            if (long.TryParse(current.id, out result) && result == occupation.id && current.year_graduated > 0)
                            {
                                str = string.Format("{0} '{1:00}", current.name, (current.year_graduated % 100));
                            }
                        }
                    }
                    finally
                    {
                        enumerator.Dispose();
                    }
                }
                occupation.name = str;
                profileInfoItemList1.Add((ProfileInfoItem)OccupationItem.GetOccupationItem(occupation, this._userData.occupationGroup));
            }
            if (this._userData.user.relation != 0)
            {
                profileInfoItemList1.Add((ProfileInfoItem) new RelationshipItem(this._userData));
            }
            if (user.personal != null && !((IList)user.personal.langs).IsNullOrEmpty())
            {
                profileInfoItemList1.Add((ProfileInfoItem) new LanguagesItem(this._userData));
            }
            if (user.relatives != null && user.relatives.Count > 0)
            {
                List <Relative> relatives1 = user.relatives;
                List <User>     relatives2 = this._userData.relatives;
                List <Relative> list1      = (List <Relative>)Enumerable.ToList <Relative>(Enumerable.Where <Relative>(relatives1, (Func <Relative, bool>)(r => r.type == RelativeType.grandparent)));
                if (!((IList)list1).IsNullOrEmpty())
                {
                    profileInfoItemList1.Add((ProfileInfoItem) new GrandparentsItem((IEnumerable <Relative>)list1, relatives2));
                }
                List <Relative> list2 = (List <Relative>)Enumerable.ToList <Relative>(Enumerable.Where <Relative>(relatives1, (Func <Relative, bool>)(r => r.type == RelativeType.parent)));
                if (!((IList)list2).IsNullOrEmpty())
                {
                    profileInfoItemList1.Add((ProfileInfoItem) new ParentsItem((IEnumerable <Relative>)list2, relatives2));
                }
                List <Relative> list3 = (List <Relative>)Enumerable.ToList <Relative>(Enumerable.Where <Relative>(relatives1, (Func <Relative, bool>)(r => r.type == RelativeType.sibling)));
                if (!((IList)list3).IsNullOrEmpty())
                {
                    profileInfoItemList1.Add((ProfileInfoItem) new SiblingsItem((IEnumerable <Relative>)list3, relatives2));
                }
                List <Relative> list4 = (List <Relative>)Enumerable.ToList <Relative>(Enumerable.Where <Relative>(relatives1, (Func <Relative, bool>)(r => r.type == RelativeType.child)));
                if (!((IList)list4).IsNullOrEmpty())
                {
                    profileInfoItemList1.Add((ProfileInfoItem) new ChildrenItem((IEnumerable <Relative>)list4, relatives2));
                }
                List <Relative> list5 = (List <Relative>)Enumerable.ToList <Relative>(Enumerable.Where <Relative>(relatives1, (Func <Relative, bool>)(r => r.type == RelativeType.grandchild)));
                if (!((IList)list5).IsNullOrEmpty())
                {
                    profileInfoItemList1.Add((ProfileInfoItem) new GrandchildrenItem((IEnumerable <Relative>)list5, relatives2));
                }
            }
            if (profileInfoItemList1.Count > 0)
            {
                this.InfoSections.Add(new ProfileInfoSectionItem()
                {
                    Items = profileInfoItemList1
                });
            }
            List <ProfileInfoItem> profileInfoItemList2 = new List <ProfileInfoItem>();

            profileInfoItemList2.AddRange((IEnumerable <ProfileInfoItem>)PhoneItem.GetPhones(this._userData));
            if (this._userData.city != null)
            {
                profileInfoItemList2.Add((ProfileInfoItem) new CityItem(this._userData.city.name));
            }
            profileInfoItemList2.Add((ProfileInfoItem) new VKSocialNetworkItem((IProfileData)this._userData));
            if (!string.IsNullOrEmpty(user.skype))
            {
                profileInfoItemList2.Add((ProfileInfoItem) new SkypeSocialNetworkItem(user.skype));
            }
            if (!string.IsNullOrEmpty(user.facebook))
            {
                profileInfoItemList2.Add((ProfileInfoItem) new FacebookSocialNetworkItem(user.facebook, user.facebook_name));
            }
            if (!string.IsNullOrEmpty(user.twitter))
            {
                profileInfoItemList2.Add((ProfileInfoItem) new TwitterSocialNetworkItem(user.twitter));
            }
            if (!string.IsNullOrEmpty(user.instagram))
            {
                profileInfoItemList2.Add((ProfileInfoItem) new InstagramSocialNetworkItem(user.instagram));
            }
            if (!string.IsNullOrEmpty(user.site))
            {
                profileInfoItemList2.Add((ProfileInfoItem) new SiteItem(user.site));
            }
            if (profileInfoItemList2.Count > 0)
            {
                this.InfoSections.Add(new ProfileInfoSectionItem(CommonResources.ProfilePage_Info_ContactInformation)
                {
                    Items = profileInfoItemList2
                });
            }
            List <ProfileInfoItem> profileInfoItemList3 = new List <ProfileInfoItem>();

            profileInfoItemList3.AddRange((IEnumerable <ProfileInfoItem>)UniversityItem.GetUniversities(user.universities, this._userData.universityGroups));
            profileInfoItemList3.AddRange((IEnumerable <ProfileInfoItem>)SchoolItem.GetSchools(user.schools, this._userData.schoolGroups));
            if (profileInfoItemList3.Count > 0)
            {
                this.InfoSections.Add(new ProfileInfoSectionItem(CommonResources.ProfilePage_Info_Education.ToUpperInvariant())
                {
                    Items = profileInfoItemList3
                });
            }
            List <ProfileInfoItem> profileInfoItemList4 = new List <ProfileInfoItem>();
            UserPersonal           personal             = user.personal;

            if (personal != null)
            {
                if (personal.political > 0 && personal.political <= 9)
                {
                    profileInfoItemList4.Add((ProfileInfoItem) new PoliticalViewsItem(personal.political));
                }
                if (!string.IsNullOrEmpty(personal.religion))
                {
                    profileInfoItemList4.Add((ProfileInfoItem) new WorldViewItem(personal.religion));
                }
                if (personal.life_main > 0 && personal.life_main <= 8)
                {
                    profileInfoItemList4.Add((ProfileInfoItem) new PersonalPriorityItem(personal.life_main));
                }
                if (personal.people_main > 0 && personal.people_main <= 6)
                {
                    profileInfoItemList4.Add((ProfileInfoItem) new ImportantInOthersItem(personal.people_main));
                }
                if (personal.smoking > 0 && personal.smoking <= 5)
                {
                    profileInfoItemList4.Add((ProfileInfoItem) new BadHabitsItem(CommonResources.ProfilePage_Info_ViewsOnSmoking, personal.smoking));
                }
                if (personal.alcohol > 0 && personal.alcohol <= 5)
                {
                    profileInfoItemList4.Add((ProfileInfoItem) new BadHabitsItem(CommonResources.ProfilePage_Info_ViewsOnAlcohol, personal.alcohol));
                }
                if (!string.IsNullOrEmpty(personal.inspired_by))
                {
                    profileInfoItemList4.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_InspiredBy, personal.inspired_by, null, ProfileInfoItemType.RichText));
                }
            }
            if (profileInfoItemList4.Count > 0)
            {
                this.InfoSections.Add(new ProfileInfoSectionItem(CommonResources.ProfilePage_Info_Beliefs)
                {
                    Items = profileInfoItemList4
                });
            }
            List <ProfileInfoItem> profileInfoItemList5 = new List <ProfileInfoItem>();

            if (!string.IsNullOrEmpty(user.activities))
            {
                profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_Activities, user.activities, null, ProfileInfoItemType.RichText));
            }
            if (!string.IsNullOrEmpty(user.interests))
            {
                profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_Interests, user.interests, null, ProfileInfoItemType.RichText));
            }
            if (!string.IsNullOrEmpty(user.music))
            {
                profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_Music, user.music, null, ProfileInfoItemType.RichText));
            }
            if (!string.IsNullOrEmpty(user.movies))
            {
                profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_Movies, user.movies, null, ProfileInfoItemType.RichText));
            }
            if (!string.IsNullOrEmpty(user.tv))
            {
                profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_TV, user.tv, null, ProfileInfoItemType.RichText));
            }
            if (!string.IsNullOrEmpty(user.books))
            {
                profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_Books, user.books, null, ProfileInfoItemType.RichText));
            }
            if (!string.IsNullOrEmpty(user.games))
            {
                profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_Games, user.games, null, ProfileInfoItemType.RichText));
            }
            if (!string.IsNullOrEmpty(user.quotes))
            {
                profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_Quotes, user.quotes, null, ProfileInfoItemType.RichText));
            }
            if (!string.IsNullOrEmpty(user.about))
            {
                profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_About, user.about, null, ProfileInfoItemType.RichText));
            }
            if (profileInfoItemList5.Count > 0)
            {
                this.InfoSections.Add(new ProfileInfoSectionItem(CommonResources.ProfilePage_Info_PersonalInfomation)
                {
                    Items = profileInfoItemList5
                });
            }
            List <ProfileInfoItem> profileInfoItemList6 = new List <ProfileInfoItem>();

            if (!((IList)user.military).IsNullOrEmpty())
            {
                profileInfoItemList6.AddRange((IEnumerable <ProfileInfoItem>)MilitaryItem.GetMilitaryItems(user.military, this._userData.militaryCountries));
                if (profileInfoItemList6.Count > 0)
                {
                    this.InfoSections.Add(new ProfileInfoSectionItem(CommonResources.ProfilePage_Info_MilitaryService)
                    {
                        Items = profileInfoItemList6
                    });
                }
            }
            List <ProfileInfoItem> profileInfoItemList7 = new List <ProfileInfoItem>();
            CareerData             careerData           = this._userData.careerData;

            if (careerData != null && !((IList)careerData.Items).IsNullOrEmpty())
            {
                profileInfoItemList7.AddRange((IEnumerable <ProfileInfoItem>)CareerItem.GetCareerItems(careerData.Items, careerData.Cities, careerData.Groups));
                if (profileInfoItemList7.Count > 0)
                {
                    this.InfoSections.Add(new ProfileInfoSectionItem(CommonResources.ProfilePage_Info_Career)
                    {
                        Items = profileInfoItemList7
                    });
                }
            }
            if (this.InfoSections.Count <= 0)
            {
                return;
            }
            ((ProfileInfoSectionItem)Enumerable.Last <ProfileInfoSectionItem>(this.InfoSections)).DividerVisibility = Visibility.Collapsed;
        }
 public void GetDropDowns(School school = null)
 {
 }
コード例 #48
0
ファイル: wupeng_0721.cs プロジェクト: koseyile/CycleTEST
    // Start is called before the first frame update
    void Start()
    {
        //01
        School school = new School();

        school.num_students = 108;
        school.num_boys     = 60;
        school.num_girls    = 48;

        school.num_Junior      = 42;
        school.num_Middle      = 36;
        school.num_Senior      = 30;
        school.boysMuch_Middle = 4;
        school.boysMuch_Senior = 0;

        //02
        Work_02(ref school);


        //03
        Book black = new Book();

        black.cost_Junior = 1900;
        black.cost_Middle = 1900;
        black.cost_Senior = 1900;

        Book white = new Book();

        white.cost_Junior = 2500;
        white.cost_Middle = 2200;
        white.cost_Senior = 2000;

        //04
        Travel travel = new Travel();

        travel.black = black;
        travel.white = white;

        Work_04(ref school, ref travel);

        //05
        Weapon redSword = new Weapon()
        {
            color = "red", name = "RedSward", length = 20, width = 4, attack = 80, defend = 20
        };

        Weapon blueShield = new Weapon()
        {
            color = "blue", name = "BlueShield", length = 15, width = 15, attack = 30, defend = 90
        };

        //06

        int a = AreaWeapon(ref redSword) + AreaWeapon(ref blueShield);

        Debug.Log("面积之和:" + a + "平方寸");

        //07
        RedLightAttack(1000, ref redSword, ref blueShield);

        //08
        Bottle_Price bp = new Bottle_Price();

        bp.generation_Price    = new int[14];
        bp.generation_Price[0] = 4000;
        bp.generation_Price[1] = 4000 / 2;
        bp.generation_Price[2] = 4000 / 2 * 10;
        bp.generation_Price[3] = 4000 / 2 * 10;

        //09
        Work_09(ref bp);

        //10
        Work_10(ref school, ref travel, ref bp);
    }
コード例 #49
0
 public void Add(School s)
 {
     context.Schools.Add(s);
     context.SaveChanges();
 }
        public async Task ImportExcelToDatabase(string filePath)
        {
            // store excel data in datatable
            DataTable data = ExcelToDatatable(filePath);

            // storage for failed rows
            DataTable failedRows = new DataTable();
            // store error messages in a list
            List <string> failedErrorMsgs = new List <string>();

            // set column headers for failedRows
            foreach (DataColumn column in data.Columns)
            {
                failedRows.Columns.Add(column.ColumnName, column.DataType);
            }
            await _context.Database.EnsureCreatedAsync();

            int successful = 0;
            int duplicate  = 0;
            int failed     = 0;

            foreach (DataRow row in data.Rows)
            {
                try
                {
                    // add Faculty Information
                    Faculty faculty = new Faculty();
                    faculty.Name = row["Availability Owning Org Unit Name"].ToString();
                    //Above COlumn does not exists in the excel provided and exception is thrown
                    //faculty.Name = row["Faculty"].ToString();

                    int latestFacultyId;
                    if (!_context.Faculty.Any(x => x.Name == faculty.Name))
                    {
                        _context.Faculty.Add(faculty);
                        await _context.SaveChangesAsync();

                        latestFacultyId = faculty.Id;
                    }
                    else
                    {
                        latestFacultyId = _context.Faculty.ToList <Faculty>().Find(x => x.Name.Equals(faculty.Name)).Id;
                    }

                    // Add school information
                    School school = new School();
                    school.Faculty = latestFacultyId;
                    school.Name    = row["Availability Teaching Parent Org Unit Name"].ToString();
                    int latestSchoolId;
                    if (!_context.School.Any(x => x.Name == school.Name))
                    {
                        _context.School.Add(school);
                        await _context.SaveChangesAsync();

                        latestSchoolId = school.Id;
                    }
                    else
                    {
                        latestSchoolId = _context.School.ToList <School>().Find(x => x.Name.Equals(school.Name)).Id;
                    }

                    // Add Department information
                    Department department = new Department();
                    department.School = latestSchoolId;
                    department.Name   = row["Availability Teaching Org Unit Name"].ToString();
                    int latestDepartmentId;

                    if (!_context.Department.Any(x => x.Name == department.Name))
                    {
                        _context.Department.Add(department);
                        await _context.SaveChangesAsync();

                        latestDepartmentId = department.Id;
                    }
                    else
                    {
                        latestDepartmentId = _context.Department.ToList <Department>().Find(x => x.Name.Equals(department.Name)).Id;
                    }

                    // Add Unit information.
                    Unit unit = new Unit();
                    unit.Department = latestDepartmentId;
                    unit.UnitCode   = row["Study Package Code"].ToString();
                    unit.UnitName   = row["Unit Title"].ToString();
                    unit.UnitLink   = row["Unit Link"].ToString();
                    int latestUnitId;
                    if (!_context.Unit.Any(x => x.UnitCode == unit.UnitCode))
                    {
                        _context.Unit.Add(unit);
                        await _context.SaveChangesAsync();

                        latestUnitId = unit.Id;
                    }
                    else
                    {
                        latestUnitId = _context.Unit.ToList <Unit>().Find(x => x.UnitCode.Equals(unit.UnitCode)).Id;
                    }

                    // Add Class information.
                    Class aClass = new Class();
                    aClass.UnitId      = latestUnitId;
                    aClass.ClassType   = row["Activities Activity Type"].ToString();
                    aClass.Location    = row["Activities Location"].ToString();
                    aClass.Year        = row["Activities Availability Year"].ToString();
                    aClass.StudyPeriod = row["Activities Study Period"].ToString();
                    aClass.DayOfWeek   = row["Activities Class Start Day"].ToString();
                    CultureInfo culture = new CultureInfo("es-ES");
                    aClass.StartDate          = DateTime.Parse(row["Activities Class Start Date"].ToString(), culture);
                    aClass.StartTimeScheduled = TimeSpan.Parse(row["Activities Class Start Time"].ToString());
                    aClass.EndTimeScheduled   = TimeSpan.Parse(row["Activities Class Session Class End Time"].ToString());
                    aClass.roomDetails        = row["Activities Class Building Id"].ToString() + row["Activities Class Room Id"].ToString();

                    // Duplicate entry check. If this row already exist in the database, skip this row.
                    if (!_context.Class.Any(x =>
                                            x.UnitId == aClass.UnitId &&
                                            x.ClassType == aClass.ClassType &&
                                            x.Location == aClass.Location &&
                                            x.Year == aClass.Year &&
                                            x.StudyPeriod == aClass.StudyPeriod &&
                                            x.DayOfWeek == aClass.DayOfWeek &&
                                            x.StartDate == aClass.StartDate &&
                                            x.StartTimeScheduled == aClass.StartTimeScheduled &&
                                            x.EndTimeScheduled == aClass.EndTimeScheduled &&
                                            x.roomDetails == aClass.roomDetails))
                    {
                        _context.Class.Add(aClass);
                        await _context.SaveChangesAsync();

                        successful++;
                    }
                    else
                    {
                        duplicate++;
                    }
                }
                catch (Exception ex)
                {
                    failedRows.Rows.Add(row.ItemArray);
                    failed++;
                    failedErrorMsgs.Add(ex.Message);
                }
            }
            TempData["StatusMessage"] = successful + " rows entered successfully, " + duplicate + " duplicate entries ignored, " + failed + " failed.";
            if (failed > 0) // used to set link to download failed data
            {
                var fileName = FailedDataToExcel(failedRows, failedErrorMsgs);
                TempData["FileName"] = fileName;
            }
        }
コード例 #51
0
 public static new SchoolViewData Create(School school)
 {
     return(new SchoolViewData(school));
 }
コード例 #52
0
 public MainWindow()
 {
     InitializeComponent();
     School.MainWindow = this;
     School.LoadAll();
 }
コード例 #53
0
 // GET: Studentdetails
 public IActionResult Index()
 {
     return(View(School.GetStudentInfoByEmailAddress(HttpContext.User.Identity.Name)));
 }
コード例 #54
0
        public ActionResult CreateForDivisionFast([Bind(Include = "SchoolId,SchoolName,ParticipantName,DivisionId,TournamentId")] FastParticipant fastParticipant)
        {
            if (string.IsNullOrEmpty(fastParticipant.ParticipantName) || (fastParticipant.SchoolId == Guid.Empty && string.IsNullOrEmpty(fastParticipant.SchoolName)))
            {
                return(RedirectToAction("Details", "Divisions", new { id = fastParticipant.DivisionId }));
            }

            var    tournament = db.Tournaments.Include(t => t.Schools).Include(t => t.Participants).Where(t => t.TournamentId == fastParticipant.TournamentId).FirstOrDefault();
            School school     = null;

            if (fastParticipant.SchoolId == Guid.Empty)
            {
                school = tournament.Schools.FirstOrDefault(s => s.Name.Equals(fastParticipant.SchoolName, StringComparison.OrdinalIgnoreCase));
                if (school == null)
                {
                    school = new School
                    {
                        Name         = fastParticipant.SchoolName,
                        SchoolId     = Guid.NewGuid(),
                        Tournament   = tournament,
                        TournamentId = fastParticipant.TournamentId
                    };
                    tournament.Schools.Add(school);
                }
                ;
            }
            else
            {
                school = db.Schools.FirstOrDefault(s => s.SchoolId == fastParticipant.SchoolId);
            }

            var participant = new Participant
            {
                Name          = fastParticipant.ParticipantName,
                School        = school,
                SchoolId      = school.SchoolId,
                Tournament    = tournament,
                TournamentId  = fastParticipant.TournamentId,
                Dummy         = false,
                ParticipantId = Guid.NewGuid()
            };


            school.Participants.Add(participant);
            tournament.Participants.Add(participant);
            db.SaveChanges();

            var transferDivision = db.Divisions.Find(fastParticipant.DivisionId);

            if (transferDivision != null)
            {
                var maxOrderID = transferDivision.ParticipantDivisionInts.Any() ? transferDivision.ParticipantDivisionInts.Max(pdi => pdi.OrderId) : 0;
                transferDivision.ParticipantDivisionInts.Add(new ParticipantDivisionInt()
                {
                    ParticipantDivisionIntId = Guid.NewGuid(),
                    ParticipantId            = participant.ParticipantId,
                    DivisionId = fastParticipant.DivisionId,
                    OrderId    = maxOrderID + 1
                });
                db.SaveChanges();
            }

            return(RedirectToAction("Details", "Divisions", new { id = fastParticipant.DivisionId }));
        }
コード例 #55
0
 public void Remove(School obj)
 {
     _schools.Remove(obj);
 }
コード例 #56
0
 protected SchoolViewData(School school) : base(school)
 {
     StudyCenterEnabledTill = school.StudyCenterEnabledTill;
     IsMessagingDisabled    = school.IsMessagingDisabled;
     IsAssessmentEnabled    = school.IsAssessmentEnabled;
 }
コード例 #57
0
 public static School AddStudent(this School sc, Student stud)
 {
     sc.Students.Add(stud);
     return(sc);
 }
コード例 #58
0
 public IActionResult DeleteConfirmed(int id)
 {
     School.RemoveStudent(id);
     return(RedirectToAction(nameof(Index)));
 }
コード例 #59
0
 public static School AddLocation(this School sc, string location)
 {
     sc.Location = location;
     return(sc);
 }
コード例 #60
0
 public void Add(School obj)
 {
     _schools.Add(obj);
 }