public IList<Evk> selectEvkVakkenPerStudent(Student s) { var vakken = (from e in dc.Evks where e.fk_studentID == s.pk_studentID select e).ToList(); return vakken; }
public IHttpActionResult PutStudent(int id, Student student) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != student.StudentIdentification) { return BadRequest(); } db.Entry(student).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
static void Main() { Student[] myClass = new Student[3]; Student firstStudent = new Student(); firstStudent.firstName = "Ivan"; firstStudent.secondName = "Zabunov"; myClass[0] = firstStudent; Student secondStudent = new Student(); secondStudent.firstName = "Teodor"; secondStudent.secondName = "Andonov"; myClass[1] = secondStudent; Student thirdStudent = new Student(); thirdStudent.firstName = "Pesho"; thirdStudent.secondName = "Olov"; myClass[2] = thirdStudent; var sortedClass = from student in myClass orderby student.firstName, student.secondName descending select student; foreach (var student in sortedClass) { Console.WriteLine("{0} {1}", student.firstName, student.secondName); } }
private void Form1_Load(object sender, EventArgs e) { Student student1 = new Student(); student1.getbyid("D12312312"); MessageBox.Show(student1.name); }
static void Main() { var student1 = new Student("John", "Atanasov", "421586353"); var studentEqual = new Student("John", "Atanasov", "421586353"); Console.WriteLine("Different objects with the same properties are equal: {0}",student1.Equals(studentEqual)); Console.WriteLine(); Student student1DeepCopy = student1.Clone(); Console.WriteLine("The copy and the original are the same: {0}", student1.Equals(student1DeepCopy)); Console.WriteLine("The copy reference the original -> " + ReferenceEquals(student1, student1DeepCopy)); Console.WriteLine(); var student2 = new Student("John", "Atanasov", "421586353"); var student3 = new Student("Peter", "Nikolov", "245124749"); CompareStudents(student1, student2); CompareStudents(student1, student3); CompareStudents(student2, student3); Console.WriteLine(); Console.WriteLine(student1.ToString()); Console.WriteLine(); student1.MiddleName = "Ivanov"; student1.MobilePhone = "0885123456"; student1.Faculty = Faculty.Bachelor; student1.University = University.SU; Console.WriteLine(student1.ToString()); Console.WriteLine(); }
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); }
public Student GetStudent(string id) { string sql = "select * from Student where id='{0}'".FormatWith(id); SqlDataReader dr = SqlHelper.ExecuteReader(ConStr, CommandType.Text, sql); if (dr.HasRows == false) return null; dr.Read(); var stu = new Student( dr["Name"].ToString(), dr["Id"].ToString(), dr["Major"].ToString(), dr["Degree"].ToString()); dr.Close(); dr.Dispose(); //访问数据库,获取选课信息 var attends = new List<Section>(); string sql1 = @"select * from AttendSection where StudentNumber ='{0}'".FormatWith(id); DataTable attendSec = SqlHelper.ExecuteDataset(ConStr, CommandType.Text, sql1).Tables[0]; var secDAO = new SectionDAO(); foreach (DataRow r in attendSec.Rows) { attends.Add(secDAO.GetSection(r["SectionNumber"].ConvertToIntBaseZero())); } stu.Attends = attends; return stu; }
static void Main(string[] args) { Student student = new Student(); Console.Write($"First Name:{student.FirstName}\n"); Console.Write($"Last Name:{student.LastName}"); Console.ReadKey(); }
static void Main(string[] args) { Instructor EnglishInstructor = new Instructor("John", "English"); Instructor MathInstructor = new Instructor("Mike", "Math"); Student Student1 = new Student("Jane", EnglishInstructor); Student Student2 = new Student("Joe", EnglishInstructor); Student Student3 = new Student("Melissa", MathInstructor); Student Student4 = new Student("Matt", MathInstructor); EnglishInstructor.SetStudentGrade(Student1, 95); EnglishInstructor.SetStudentGrade(Student2, 85); MathInstructor.SetStudentGrade(Student3, 90); MathInstructor.SetStudentGrade(Student4, 92); System.Console.WriteLine(" Student Information "); System.Console.WriteLine(" "); Student1.Print(); Student2.Print(); Student3.Print(); Student4.Print(); System.Console.ReadKey(); }
public void validateStudent(Student s) { if (this.nameIsEmpty(s.getName())) throw new MyException("Name cannot be empty!\n"); if (this.studentExists(s.getID())) throw new MyException("Student id already exists!\n"); }
static void Main(string[] args) { Console.WriteLine(GeometryCalculations.TriangleArea(3, 4, 5)); Console.WriteLine(NumericConversions.DigitToString(5)); Console.WriteLine(ArithmethicCalculations.FindMaxValue(5, -1, 3, 2, 14, 2, 3)); ConsoleMethods.PrintNumberWithPrecision(1.3, 2); ConsoleMethods.PrintNumberAsPercentWithPrecision(0.75, 0); ConsoleMethods.PrintObjectAsPaddedString(2.30, 8); Console.WriteLine(GeometryCalculations.DistanceBetweenTwoPoints(3, -1, 3, 2.5)); Console.WriteLine("Horizontal? " + GeometryCalculations.IsHorizontal(3, -1, 3, 2.5)); Console.WriteLine("Vertical? " + GeometryCalculations.IsVertical(3, -1, 3, 2.5)); Student peter = new Student() { FirstName = "Peter", LastName = "Ivanov" }; peter.OtherInfo = "From Sofia, born at 17.03.1992"; Student stella = new Student() { FirstName = "Stella", LastName = "Markova" }; stella.OtherInfo = "From Vidin, gamer, high results, born at 03.11.1993"; Console.WriteLine("{0} older than {1} -> {2}", peter.FirstName, stella.FirstName, peter.IsOlderThan(stella)); }
static void Main() { Student pesho = new Student("Pesho", "Peshev", "Peshev", 10025030, "Mladost 1", "+359888777222", "*****@*****.**", 2, Specialty.Engineering, University.TU, Faculty.FEn); Student gosho = new Student("Gosho", "Goshev", "Goshev", 10030020, "Druzhba 2", "0888500300", "*****@*****.**", 3, Specialty.Informatics, University.SofiaUniversity, Faculty.FI); Console.WriteLine(new string('-',50)); Console.WriteLine("Getting hashcodes: "); Console.WriteLine(pesho.GetHashCode()); Console.WriteLine(gosho.GetHashCode()); Console.WriteLine(new string('-', 50)); Console.WriteLine(pesho); Console.WriteLine(gosho); Console.WriteLine(new string('-', 50)); Console.WriteLine("Is pesho equal to gosho?"); Console.WriteLine(pesho.Equals(gosho)); Console.WriteLine(pesho==gosho); Console.WriteLine("Is pesho different from gosho?"); Console.WriteLine(pesho!=gosho); Console.WriteLine(new string('-', 50)); Student pesho1 = pesho.Clone() as Student; Console.WriteLine(pesho1); Console.WriteLine(new string('-', 50)); Console.WriteLine(pesho.CompareTo(gosho)); Console.WriteLine(gosho.CompareTo(pesho)); Console.WriteLine(pesho.CompareTo(pesho1)); }
/// <summary> /// Adds the student to a course offering. /// </summary> /// <param name="student">The student.</param> /// <param name="courseOfferingId">The course offering identifier.</param> public void AddStudentToCourseOffering(Student student, int courseOfferingId) { using (_courseOfferingRepository) { _courseOfferingRepository.InsertStudentIntoCourseOffering(student, courseOfferingId); } }
public void CourseShouldThrowExceptionWhenExistingStudentAdded() { var course = new Course("HQC"); Student student = new Student("Nikolay Kostov", 10000); course.AddStudent(student); course.AddStudent(student); }
static void Main(string[] args) { //Define a class Student, which contains data about a student – first, middle and last name, //SSN, permanent address, mobile phone e-mail, course, specialty, university, faculty. Use //an enumeration for the specialties, universities and faculties. Override the standard methods, //inherited by System.Object: Equals(), ToString(), GetHashCode() and operators == and !=. //Add implementations of the ICloneable interface. The Clone() method should deeply copy all //object's fields into a new object of type Student. //Implement the IComparable<Student> interface to compare students by names (as first criteria, //in lexicographic order) and by social security number (as second criteria, in increasing order). //Making student and test override ToString method Student peter = new Student("Peter", "Ivanov", "Petrov", 12764397, "Sofia,Mladost1,Al. Malinov str.", 0889888888, "*****@*****.**", 2, Universities.SofiaUniversity, Faculties.HistoryFaculty, Specialties.History); Console.WriteLine(peter); Console.WriteLine(); //Make second student who is deep clone of the first one and test this Student ivo = peter.Clone(); Console.WriteLine(ivo); ivo.FirstName = "Joro"; Console.WriteLine(ivo.FirstName); Console.WriteLine(peter.FirstName); Console.WriteLine(); //Testing override method CompareTo Console.WriteLine(peter.CompareTo(ivo)); ivo.FirstName = "Peter"; Console.WriteLine(peter.CompareTo(ivo)); }
static void Main(string[] args) { // test the constructor with initializerz Student firstStudent = new Student("Petar", "Ivanov", "Georgiev", "3210-2112-35435", "Sofia, Vasil Levski Str., No 201", "0888197143", "*****@*****.**", "Java Programming", Specialty.ComputerScience, Faculty.MathsAndInformatics, University.SofiaUniversity); // test the Clone() method Student cloned = (Student)firstStudent.Clone(); // test the ToString() method Console.WriteLine("Information about the first student:"); Console.WriteLine(firstStudent.ToString()); Console.WriteLine("Information about the cloned student: "); Console.WriteLine(cloned.ToString()); //test the equality operator Console.WriteLine("The two students are equal: {0}", firstStudent == cloned); cloned.MiddleName = "Dimitrov"; cloned.SSN = "98978989-8984934-0435"; //test the CompareTo() method Console.WriteLine("Some properties were changed. CompareTo returns: {0}", firstStudent.CompareTo(cloned)); }
protected void Page_Load(object sender, EventArgs e) { lblError.Text = ""; Label1.Visible = true; Label2.Visible = true; Label3.Visible = true; Label4.Visible = true; string BannerID= (Request.QueryString["bannerid"] == null) ? "0" : Convert.ToString(Request.QueryString["bannerid"]); Session["BannerID"] = BannerID; Student std = new Student(); std = std.GetStudentByStudentBannerID(BannerID); if (std != null) { lblBannerID.Text = std.StudentID; lblFirstName.Text = std.FirstName; lblLastName.Text = std.LastName; lblMiddleName.Text = std.MiddleName; lblTerm.Text = std.ProgramEnrollment; lblProgram.Text = std.MajorProgramEnrollment; } else if (std == null || BannerID=="0") { Label1.Visible = false ; Label2.Visible = false ; Label3.Visible = false ; Label4.Visible = false ; lblError.Text = "Error Occured During Registration Process. Please Try again..."; } }
public StudentsViewModel(string sortOrder) { Student = new Student(); Students = db.Students.ToList(); switch (sortOrder) { case "": case "name_asc": NameSortOrder = "name_desc"; DateSortOrder = "date_asc"; Students = Students.OrderBy(s => s.LastName).ToList(); break; case "name_desc": NameSortOrder = "name_asc"; DateSortOrder = "date_asc"; Students = Students.OrderByDescending(s => s.LastName).ToList(); break; case "date_asc": NameSortOrder = "name_asc"; DateSortOrder = "date_desc"; Students = Students.OrderBy(s => s.EnrollmentDate).ToList(); break; case "date_desc": NameSortOrder = "name_asc"; DateSortOrder = "date_asc"; Students = Students.OrderByDescending(s => s.EnrollmentDate).ToList(); break; default: Students = Students.OrderBy(s => s.LastName).ToList(); break; } }
private static void Main() { SortedDictionary<string, List<Student>> courses = new SortedDictionary<string, List<Student>>(); string studentsFilePath = "../../Resources/students.txt"; using (StreamReader reader = new StreamReader(studentsFilePath)) { string line; while ((line = reader.ReadLine()) != null) { string[] recordData = line.Split('|'); string firstName = recordData[0].Trim(); string lastName = recordData[1].Trim(); string course = recordData[2].Trim(); List<Student> students; if (!courses.TryGetValue(course, out students)) { students = new List<Student>(); courses.Add(course, students); } Student student = new Student(firstName, lastName); students.Add(student); } } foreach (var pair in courses) { Console.WriteLine("{0,15}:\n\t\t{1}", pair.Key, string.Join("\n\t\t", pair.Value)); } }
static void Main() { Disciplines disclineOne = new Disciplines("math", 10, 12); Disciplines[] discipline = new Disciplines[] { disclineOne}; Teacher teacherOne = new Teacher("Ivan Ivanov", discipline); Teacher[] teachers = new Teacher[] { teacherOne }; Student studentOne = new Student("Stoyan", 1); Student studentTwo = new Student("Daniel", 2); Student studentThree = new Student("Yavor", 3); Student studentFour = new Student("Pesho", 5); Student studentFive = new Student("Darin", 8); Student [] students = new Student[]{studentOne,studentTwo,studentThree,studentFour,studentFive}; ClassesOfStudents classOne = new ClassesOfStudents(teachers, students, "6C"); classOne.AddTeacher(teacherOne); classOne.AddStudent(studentOne); classOne.AddStudent(studentFour); foreach (var s in students) { Console.WriteLine("Name of student:{0}",s.Name); } studentOne.AddText("vacation is over"); Console.WriteLine("The commnent of student is: {0}", studentOne.FreeTexts[0]); }
/* 02. Write a console application that uses the data.*/ /// <summary> /// Mains this instanse. /// </summary> public static void Main() { Database.SetInitializer(new MigrateDatabaseToLatestVersion<StudentSystemContext, Configuration>()); using (var db = new StudentSystemContext()) { var pesho = new Student { Name = "Pesho", Number = 666 }; db.Students.Add(pesho); db.SaveChanges(); var dbCourse = new Course { Name = "Database Course", Description = "Basic Database operations", Materials = "http://telerikacademy.com/Courses/Courses/Details/98" }; db.Courses.Add(dbCourse); db.SaveChanges(); var course = db.Courses.First(c => c.Name == dbCourse.Name); var student = db.Students.First(s => s.Number == pesho.Number); var hw = new Homework { Content = "Empty Homework", TimeSent = DateTime.Now, CourseId = course.CourseId, StudentId = student.StudentID }; db.Homeworks.Add(hw); db.SaveChanges(); } ListStudents(); }
private static Student[] FirstLastNameCompare(Student[] students) { return students .Where(x => x.FirstName.CompareTo(x.LastName) < 0) .Select(x => x) .ToArray<Student>(); }
public void StudentLeavingCourseShouldNotThrowException() { Student student = new Student("Humpty Dumpty", 10000); Course course = new Course("Unit Testing"); student.AttendCourse(course); student.LeaveCourse(course); }
static void Main(string[] args) { //Create Instructor Instructor John = new Instructor("John", "English"); Instructor Mike = new Instructor("Mike", "Math"); //Create Students Student Jane = new Student("Jane", John); Student Joe = new Student("Joe", John); Student Melissa = new Student("Melissa", Mike); Student Matt = new Student("Matt", Mike); //Instructor Set Student Grade John.StudentGrade(Jane, 95); John.StudentGrade(Joe, 85); Mike.StudentGrade(Melissa, 90); Mike.StudentGrade(Matt, 92); //Print Instructor Information John.PrintInstructorInfo(); Mike.PrintInstructorInfo(); //Print Student Information Jane.PrintStudentInfo(); Joe.PrintStudentInfo(); Melissa.PrintStudentInfo(); Matt.PrintStudentInfo(); System.Console.ReadKey(); }
public static Student create(string matricId, string password, string name = "student") { using (var context = new EventContainer()) { var existedStudent = (from s in context.Students.Include("OwnedEvents").Include("RegisteredEvents") where s.MatricId == matricId select s).FirstOrDefault(); if (existedStudent != null) { // a student with this matriculation number exists return existedStudent; } var newStudent = new Student { MatricId = matricId, Password = password, Name = name, }; context.Students.Add(newStudent); context.SaveChanges(); return newStudent; } }
protected void btnSave_Click(object sender, EventArgs e) { //connect using (DefaultConnection db = new DefaultConnection()) { //creating new student Student stu = new Student(); Int32 StudentID = 0; //check for a url if (!String.IsNullOrEmpty(Request.QueryString["StudentID"])) { //get the id StudentID = Convert.ToInt32(Request.QueryString["StudentID"]); //look up student stu = (from s in db.Students where s.StudentID == StudentID select s).FirstOrDefault(); } //properties for new students stu.LastName = txtLast.Text; stu.FirstMidName = txtFirst.Text; stu.EnrollmentDate = Convert.ToDateTime(txtEnroll.Text); if (StudentID == 0) { db.Students.Add(stu); } //save new students db.SaveChanges(); //send back to student page Response.Redirect("Students.aspx"); } }
static void Main(string[] args) { //Create 3 test students Student firstStudent = new Student("Gosho", "Ivanov", "Peshov", "11122", "Gosho Street", "02423423", "*****@*****.**", 1, Universities.HarvardUniversity, Faculties.FacultyOfComputerScience ,Specialties.ComputerGraphics); Student secondStudent = new Student("Ivan", "Georgiev", "Alexandrov", "15624", "Pesho Street", "09415743", "*****@*****.**", 2, Universities.MassachusettsInstituteofTechnology, Faculties.FacultyOfComputerScience, Specialties.ArtificialIntelligence); Student thirdStudent = new Student("Gosho", "Ivanov", "Peshov", "10021", "Ivan Street", "931234", "*****@*****.**", 1, Universities.SofiaUniversity, Faculties.FacultyOfComputerScience, Specialties.ComputerProgramming); //Clone a student from the first Student clonedStundent = firstStudent.Clone() as Student; Console.WriteLine(firstStudent.ToString()); Console.WriteLine(secondStudent.ToString()); Console.WriteLine(thirdStudent.ToString()); Console.WriteLine("First student == Second Student ?:{0}", firstStudent == secondStudent); Console.WriteLine("First student != Third Student ?:{0}", firstStudent != thirdStudent); Console.WriteLine("First student Equals Cloned Student ?:{0}", firstStudent.Equals(clonedStundent)); Console.WriteLine("First student compared to Second Student (in ints): {0}", firstStudent.CompareTo(secondStudent)); Console.WriteLine("First student compared to Third Student (in ints): {0}", firstStudent.CompareTo(thirdStudent)); Console.WriteLine("First student compared to Cloned Student (in ints): {0}", firstStudent.CompareTo(clonedStundent)); //Before change Console.WriteLine("Is first student number equal to cloned first student number ? {0}", firstStudent.MobilePhone == clonedStundent.MobilePhone); //The first student changes his number firstStudent.MobilePhone = "088888888"; //Compare the cloned first student to the changed one Console.WriteLine("Is first student number equal to cloned first student number ? {0}", firstStudent.MobilePhone == clonedStundent.MobilePhone); }
static void Main(string[] args) { Instructor John = new Instructor("John", "English"); Instructor Mike = new Instructor("MIKE", "Math"); Student Jane = new Student("Jane", John); Student Joe = new Student("Joe", John); Student Melissa = new Student("Melissa", Mike); Student Matt = new Student("Matt", Mike); John.SetStudentGrade(Jane, 95); John.SetStudentGrade(Joe, 85); Mike.SetStudentGrade(Melissa, 90); Mike.SetStudentGrade(Matt, 92); Jane.PrintStudentInfo(); Joe.PrintStudentInfo(); Melissa.PrintStudentInfo(); Matt.PrintStudentInfo(); System.Console.WriteLine(); System.Console.ReadKey(); }
public void CanHandleQueriesOnDictionaries() { using(var store = NewDocumentStore()) { using (var session = store.OpenSession()) { //now the student: var student = new Student { Attributes = new Dictionary<string, string> { {"NIC", "studentsNICnumberGoesHere"} } }; session.Store(student); session.SaveChanges(); } //Testing query on attribute using (var session = store.OpenSession()) { var result = from student in session.Query<Student>() where student.Attributes["NIC"] == "studentsNICnumberGoesHere" select student; var test = result.ToList(); Assert.NotEmpty(test); } } }
private static Student[] FirstLastNameCompareLinq(Student[] students) { var result = from student in students where student.FirstName.CompareTo(student.LastName) < 0 select student; return result.ToArray(); }
public StudentDepartmentViewModel GetStudentById(Student student) { return(_studentGateway.GetStudentById(student)); }
//-------------------------------------------------------End----------------------------------------------------------- //----------------------------------------Test supervisor name of student---------------------------------------------- //-------------------------------------------------------Start--------------------------------------------------------- public void DisplaySupervisorName(Student s, List <Researcher> r) { Console.WriteLine("Supervisors Name: {0}", s.SupervisorsName(r)); }
//-----------------------------------------------------------End--------------------------------------------------------------------- //----------------------------------Test to print all the researcher details and publications--------------------------- //----------------------------------------------------Full Test Start------------------------------------------------------------------------------ public void TestResearcherListByID(int id) { LoadResearcherDetails(new Researcher { ID = id }); Console.WriteLine("Name: {0} {1}\nTitle:{2}\nUnit: {3}\nCampus: {4}\nEmail: {5}\n" + "Photo: {6}\nCurrent job: {7}\nCommenced with institution: {8}\n" + "Commenced current position: {9}\nPrevious positions: \n", currentResearcher.GivenName, currentResearcher.FamilyName, currentResearcher.Title, currentResearcher.Unit, currentResearcher.Campus, currentResearcher.Email, currentResearcher.Photo, currentResearcher.GetCurrentJob().Title(), currentResearcher.GetEarliestJob().Start.ToString("dd/MM/yyyy"), currentResearcher.GetCurrentJob().Start.ToString("dd/MM/yyyy")); //Test to print all the positions of the researcher (not include student) foreach (Position pos in currentResearcher.positions) { if (pos.End != default) { Console.WriteLine(String.Format("{0}\t{1}\t{2}\n", pos.Start.ToString("dd/MM/yyyy"), pos.End.ToString("dd/MM/yyyy"), pos.Title())); } ; } Console.WriteLine("Tenure: {0}\tPublications: {1}\n", currentResearcher.Tenure().ToString("0.0"), currentResearcher.PublicationsCount()); //Staff information Console.WriteLine("More information: \n"); LoadStudentDetails(); if (currentResearcher.position.Level != EmploymentLevel.Student) { Staff staff = new Staff(currentResearcher) { students = students }; TestStaff(); DisplayNumberOfSupervisions(staff); } //Student information else { Student s = (from stu in students where stu.ID == currentResearcher.ID select stu).SingleOrDefault(); DisplayDegreeForStudent(s); DisplaySupervisorName(s, res); } //List of publication PublicationsController pc = new PublicationsController(); List <Publication> sortedPub = pc.SortPublicationList(currentResearcher); Console.WriteLine("Publication count:"); pc.TestPublicationsCount(currentResearcher); Console.WriteLine("{0,-10} {1}\n", "Year", "Title"); foreach (Publication pub in sortedPub) { Console.WriteLine("{0,-10} {1}\n", pub.Year, pub.Title); } Console.WriteLine("Publication details: \n"); pc.LoadPublicationsFor(currentResearcher); pc.TestPublicationDetails(currentResearcher); }
public async Task CreateStudent(Student student) { _dbContext.Students.Add(student); await _dbContext.SaveChangesAsync(); }
public static void Initialize(SchoolContext context) { // context.Database.EnsureCreated(); // Look for any students. if (context.Student.Any()) { return; // DB has been seeded } // creating the Student test data var students = new Student[] { new Student { FirstMidName = "Carson", LastName = "Alexander", EnrollmentDate = DateTime.Parse("2010-09-01") }, new Student { FirstMidName = "Meredith", LastName = "Alonso", EnrollmentDate = DateTime.Parse("2012-09-01") }, new Student { FirstMidName = "Arturo", LastName = "Anand", EnrollmentDate = DateTime.Parse("2013-09-01") }, new Student { FirstMidName = "Gytis", LastName = "Barzdukas", EnrollmentDate = DateTime.Parse("2012-09-01") }, new Student { FirstMidName = "Yan", LastName = "Li", EnrollmentDate = DateTime.Parse("2012-09-01") }, new Student { FirstMidName = "Peggy", LastName = "Justice", EnrollmentDate = DateTime.Parse("2011-09-01") }, new Student { FirstMidName = "Laura", LastName = "Norman", EnrollmentDate = DateTime.Parse("2013-09-01") }, new Student { FirstMidName = "Nino", LastName = "Olivetto", EnrollmentDate = DateTime.Parse("2005-09-01") } }; foreach (Student s in students) { context.Student.Add(s); } context.SaveChanges(); // create Instructor Data var instructors = new Instructor[] { new Instructor { FirstMidName = "Kim", LastName = "Abercrombie", HireDate = DateTime.Parse("1995-03-11") }, new Instructor { FirstMidName = "Fadi", LastName = "Fakhouri", HireDate = DateTime.Parse("2002-07-06") }, new Instructor { FirstMidName = "Roger", LastName = "Harui", HireDate = DateTime.Parse("1998-07-01") }, new Instructor { FirstMidName = "Candace", LastName = "Kapoor", HireDate = DateTime.Parse("2001-01-15") }, new Instructor { FirstMidName = "Roger", LastName = "Zheng", HireDate = DateTime.Parse("2004-02-12") } }; foreach (Instructor i in instructors) { context.Instructors.Add(i); } context.SaveChanges(); //create Department data var departments = new Department[] { new Department { Name = "English", Budget = 350000, StartDate = DateTime.Parse("2007-09-01"), InstructorID = instructors.Single( i => i.LastName == "Abercrombie").ID }, new Department { Name = "Mathematics", Budget = 100000, StartDate = DateTime.Parse("2007-09-01"), InstructorID = instructors.Single( i => i.LastName == "Fakhouri").ID }, new Department { Name = "Engineering", Budget = 350000, StartDate = DateTime.Parse("2007-09-01"), InstructorID = instructors.Single( i => i.LastName == "Harui").ID }, new Department { Name = "Economics", Budget = 100000, StartDate = DateTime.Parse("2007-09-01"), InstructorID = instructors.Single( i => i.LastName == "Kapoor").ID } }; foreach (Department d in departments) { context.Departments.Add(d); } context.SaveChanges(); // create Course test data var courses = new Course[] { new Course {CourseID = 1050, Title = "Chemistry", Credits = 3, DepartmentID = departments.Single( s => s.Name == "Engineering").DepartmentID }, new Course {CourseID = 4022, Title = "Microeconomics", Credits = 3, DepartmentID = departments.Single( s => s.Name == "Economics").DepartmentID }, new Course {CourseID = 4041, Title = "Macroeconomics", Credits = 3, DepartmentID = departments.Single( s => s.Name == "Economics").DepartmentID }, new Course {CourseID = 1045, Title = "Calculus", Credits = 4, DepartmentID = departments.Single( s => s.Name == "Mathematics").DepartmentID }, new Course {CourseID = 3141, Title = "Trigonometry", Credits = 4, DepartmentID = departments.Single( s => s.Name == "Mathematics").DepartmentID }, new Course {CourseID = 2021, Title = "Composition", Credits = 3, DepartmentID = departments.Single( s => s.Name == "English").DepartmentID }, new Course {CourseID = 2042, Title = "Literature", Credits = 4, DepartmentID = departments.Single( s => s.Name == "English").DepartmentID }, }; foreach (Course c in courses) { context.Courses.Add(c); } context.SaveChanges(); // create OfficeAssignment data var officeAssignments = new OfficeAssignment[] { new OfficeAssignment { InstructorID = instructors.Single( i => i.LastName == "Fakhouri").ID, Location = "Smith 17" }, new OfficeAssignment { InstructorID = instructors.Single( i => i.LastName == "Harui").ID, Location = "Gowan 27" }, new OfficeAssignment { InstructorID = instructors.Single( i => i.LastName == "Kapoor").ID, Location = "Thompson 304" }, }; foreach (OfficeAssignment o in officeAssignments) { context.OfficeAssignments.Add(o); } context.SaveChanges(); // create CourseAssignment data var courseInstructors = new CourseAssignment[] { new CourseAssignment { CourseID = courses.Single(c => c.Title == "Chemistry" ).CourseID, InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID }, new CourseAssignment { CourseID = courses.Single(c => c.Title == "Chemistry" ).CourseID, InstructorID = instructors.Single(i => i.LastName == "Harui").ID }, new CourseAssignment { CourseID = courses.Single(c => c.Title == "Microeconomics" ).CourseID, InstructorID = instructors.Single(i => i.LastName == "Zheng").ID }, new CourseAssignment { CourseID = courses.Single(c => c.Title == "Macroeconomics" ).CourseID, InstructorID = instructors.Single(i => i.LastName == "Zheng").ID }, new CourseAssignment { CourseID = courses.Single(c => c.Title == "Calculus" ).CourseID, InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID }, new CourseAssignment { CourseID = courses.Single(c => c.Title == "Trigonometry" ).CourseID, InstructorID = instructors.Single(i => i.LastName == "Harui").ID }, new CourseAssignment { CourseID = courses.Single(c => c.Title == "Composition" ).CourseID, InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID }, new CourseAssignment { CourseID = courses.Single(c => c.Title == "Literature" ).CourseID, InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID }, }; foreach (CourseAssignment ci in courseInstructors) { context.CourseAssignments.Add(ci); } context.SaveChanges(); // create Enrollment test data var enrollments = new Enrollment[] { new Enrollment { StudentID = students.Single(s => s.LastName == "Alexander").ID, CourseID = courses.Single(c => c.Title == "Chemistry" ).CourseID, Grade = Grade.A }, new Enrollment { StudentID = students.Single(s => s.LastName == "Alexander").ID, CourseID = courses.Single(c => c.Title == "Microeconomics" ).CourseID, Grade = Grade.C }, new Enrollment { StudentID = students.Single(s => s.LastName == "Alexander").ID, CourseID = courses.Single(c => c.Title == "Macroeconomics" ).CourseID, Grade = Grade.B }, new Enrollment { StudentID = students.Single(s => s.LastName == "Alonso").ID, CourseID = courses.Single(c => c.Title == "Calculus" ).CourseID, Grade = Grade.B }, new Enrollment { StudentID = students.Single(s => s.LastName == "Alonso").ID, CourseID = courses.Single(c => c.Title == "Trigonometry" ).CourseID, Grade = Grade.B }, new Enrollment { StudentID = students.Single(s => s.LastName == "Alonso").ID, CourseID = courses.Single(c => c.Title == "Composition" ).CourseID, Grade = Grade.B }, new Enrollment { StudentID = students.Single(s => s.LastName == "Anand").ID, CourseID = courses.Single(c => c.Title == "Chemistry" ).CourseID }, new Enrollment { StudentID = students.Single(s => s.LastName == "Anand").ID, CourseID = courses.Single(c => c.Title == "Microeconomics").CourseID, Grade = Grade.B }, new Enrollment { StudentID = students.Single(s => s.LastName == "Barzdukas").ID, CourseID = courses.Single(c => c.Title == "Chemistry").CourseID, Grade = Grade.B }, new Enrollment { StudentID = students.Single(s => s.LastName == "Li").ID, CourseID = courses.Single(c => c.Title == "Composition").CourseID, Grade = Grade.B }, new Enrollment { StudentID = students.Single(s => s.LastName == "Justice").ID, CourseID = courses.Single(c => c.Title == "Literature").CourseID, Grade = Grade.B } }; foreach (Enrollment e in enrollments) { var enrollmentInDataBase = context.Enrollment.Where( s => s.Student.ID == e.StudentID && s.Course.CourseID == e.CourseID).SingleOrDefault(); if (enrollmentInDataBase == null) { context.Enrollment.Add(e); } } context.SaveChanges(); }
private ExcelWorksheet CreateDetailWorksheet(int subjectID, int semesterID) { SubjectBusiness SuBO = new SubjectBusiness(); SemesterBusiness sem = new SemesterBusiness(); //get value semester, student, subject String semestername = sem.GetSemesterByID(semesterID).SemesterName; String subjectname = SuBO.GetSubjectByID(subjectID).FullName; String subshortname = SuBO.GetSubjectByID(subjectID).ShortName; ExcelWorksheet DetailWorkSheet = new ExcelPackage().Workbook.Worksheets.Add(subshortname + "_" + semestername); // get student list absent > 20% RollCallBusiness RoBO = new RollCallBusiness(); AttendanceBusiness BO = new AttendanceBusiness(); List<Student> students = new List<Student>(); List<RollCall> rollcalls = RoBO.GetList().Where(r => r.SubjectID == subjectID && r.SemesterID == semesterID).ToList(); List<int> studentID = new List<int>(); foreach (var rollcall in rollcalls) { var AttendanceLogs = BO.GetRollCallAttendanceLog(rollcall.RollCallID); int NumberOfSlot = rollcall.StudySessions.Count; var Students = rollcall.Students; for (int i = 0; i < Students.Count; i++) { int RowIndex = 7 + i; Student CurrentStudent = Students.ElementAt(i); double AbsentSession = CurrentStudent. StudentAttendances.Count(sa => AttendanceLogs.Select(a => a.LogID) .Contains(sa.AttendanceLog.LogID) && !sa.IsPresent); double AbsentRate = AbsentSession / NumberOfSlot * 100; //Neu nghi qua 20% if (AbsentRate > 20) { // check student is exist in list bool checkstuexit = studentID.Exists(r => r == CurrentStudent.StudentID); if (!checkstuexit) { studentID.Add(CurrentStudent.StudentID); students.Add(CurrentStudent); } } } } //write file DetailWorkSheet.Cells["A:XFD"].Style.Font.Name = "Arial"; DetailWorkSheet.Cells["C2"].Value = "List of student unqualified for examination report"; DetailWorkSheet.Cells["C2"].Style.Font.Size = 18; DetailWorkSheet.Cells["C2"].Style.Font.Bold = true; //semester detail DetailWorkSheet.Cells["C3"].Value = "Semester"; DetailWorkSheet.Cells["C4"].Value = "Subject"; DetailWorkSheet.Cells["C3:C4"].Style.Font.Size = 12; DetailWorkSheet.Cells["C3:C4"].Style.Font.Bold = true; DetailWorkSheet.Cells["D3"].Value = semestername; DetailWorkSheet.Cells["D4"].Value = subjectname; //title table DetailWorkSheet.Cells["B6"].Value = "No."; DetailWorkSheet.Cells["C6"].Value = "Student Name"; DetailWorkSheet.Cells["D6"].Value = "Student Code"; DetailWorkSheet.Cells["E6"].Value = "Class"; DetailWorkSheet.Cells["B6:E6"].Style.Font.Size = 12; DetailWorkSheet.Cells["B6:E6"].Style.Font.Bold = true; //body table var studentlist = students; for (int i = 0; i < studentlist.Count(); i++) { int RowIndex = 7 + i; DetailWorkSheet.Cells["B" + RowIndex].Value = i + 1; DetailWorkSheet.Cells["C" + RowIndex].Value = studentlist.ElementAt(i).FullName; DetailWorkSheet.Cells["D" + RowIndex].Value = studentlist.ElementAt(i).StudentCode; DetailWorkSheet.Cells["E" + RowIndex].Value = studentlist.ElementAt(i).Class.ClassName; } //set border table for (int column = 2; column <= 5; column++) { for (int row = 6; row <= 6 + studentlist.Count(); row++) { DetailWorkSheet.Cells[row, column].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.Black); } } //set height , width DetailWorkSheet.Cells["C2:D2"].Merge = true; DetailWorkSheet.Cells["C2:D2"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; DetailWorkSheet.Column(2).Width = 5; DetailWorkSheet.Column(3).Width = 25; DetailWorkSheet.Column(4).Width = 60; DetailWorkSheet.Column(5).Width = 12; return DetailWorkSheet; }
private ExcelWorksheet CreateGeneralWorksheet(int id) { ExcelWorksheet GeneralWorksheet = new ExcelPackage().Workbook.Worksheets.Add("General Report"); GeneralWorksheet.Cells["A:XFD"].Style.Font.Name = "Arial"; GeneralWorksheet.Cells["C2"].Value = "List of student unqualified for examination report"; GeneralWorksheet.Cells["C2"].Style.Font.Size = 18; GeneralWorksheet.Cells["C2"].Style.Font.Bold = true; //get value semester, student, subject SemesterBusiness sem = new SemesterBusiness(); SubjectBusiness sub = new SubjectBusiness(); String semestername = sem.GetSemesterByID(id).SemesterName; String begindate = sem.GetSemesterByID(id).BeginDate.ToString("dd-MM-yyyy"); String enddate = sem.GetSemesterByID(id).EndDate.ToString("dd-MM-yyyy"); RollCallBusiness rc = new RollCallBusiness(); List<RollCall> rollcalls = new List<RollCall>(); int numsub = 0; int numstu = 0; int numfstu = 0; rollcalls = rc.GetList().Where(r => r.SemesterID == id).ToList(); List<int> subid = new List<int>(); List<int> stuid = new List<int>(); List<int> fstuid = new List<int>(); // list num student absent for each subject List<int> numabsent = new List<int>(); // list check subject list have student relearn. List<int> subj = new List<int>(); List<Subject> subjectlist = new List<Subject>(); foreach (var rollcall in rollcalls) { // check subject is exit in list bool checksub = subid.Exists(r => r == rollcall.SubjectID); if (!checksub) { subid.Add(rollcall.SubjectID); numsub++; } List<Student> students = new List<Student>(); students = rollcall.Students.ToList(); foreach (var student in students) { bool checkstu = stuid.Exists(r => r == student.StudentID); if (!checkstu) { stuid.Add(student.StudentID); numstu++; } } AttendanceBusiness BO = new AttendanceBusiness(); var AttendanceLogs = BO.GetRollCallAttendanceLog(rollcall.RollCallID); int NumberOfSlot = rollcall.StudySessions.Count; var Students = rollcall.Students; for (int i = 0; i < Students.Count; i++) { int RowIndex = 7 + i; Student CurrentStudent = Students.ElementAt(i); double AbsentSession = CurrentStudent. StudentAttendances.Count(sa => AttendanceLogs.Select(a => a.LogID) .Contains(sa.AttendanceLog.LogID) && !sa.IsPresent); double AbsentRate = AbsentSession / NumberOfSlot * 100; //Neu nghi qua 20% if (AbsentRate > 20) { bool checkfstu = fstuid.Exists(r => r == CurrentStudent.StudentID); if (!checkfstu) { fstuid.Add(CurrentStudent.StudentID); numfstu++; } bool checkfailsubject = subj.Exists(r => r == rollcall.SubjectID); if (!checkfailsubject) { subj.Add(rollcall.SubjectID); var subject = sub.GetSubjectByID(rollcall.SubjectID); subjectlist.Add(subject); } numabsent.Add(rollcall.SubjectID); } } } //write file GeneralWorksheet.Cells["C2:D2"].Merge = true; GeneralWorksheet.Cells["C2:D2"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; GeneralWorksheet.Cells["C3"].Value = "Semester "; GeneralWorksheet.Cells["C4"].Value = "Time "; GeneralWorksheet.Cells["C5"].Value = "Total subjects"; GeneralWorksheet.Cells["C6"].Value = "Total students"; GeneralWorksheet.Cells["C7"].Value = "Total students unqualified for examination"; GeneralWorksheet.Cells["C3:C7"].Style.Font.Size = 12; GeneralWorksheet.Cells["C3:C7"].Style.Font.Bold = true; GeneralWorksheet.Cells["D3"].Value = semestername; GeneralWorksheet.Cells["D4"].Value = "From " + begindate + " to " + enddate; GeneralWorksheet.Cells["D5"].Value = numsub; GeneralWorksheet.Cells["D6"].Value = numstu; GeneralWorksheet.Cells["D7"].Value = numfstu; GeneralWorksheet.Cells["B9"].Value = "No."; GeneralWorksheet.Cells["C9"].Value = "Subject"; GeneralWorksheet.Cells["D9"].Value = "Number of students unqualified for examination"; GeneralWorksheet.Cells["B9:D9"].Style.Font.Size = 12; GeneralWorksheet.Cells["B9:D9"].Style.Font.Bold = true; var subjects = subjectlist; for (int i = 0; i < subjects.Count(); i++) { int RowIndex = 10 + i; GeneralWorksheet.Cells["B" + RowIndex].Value = i + 1; GeneralWorksheet.Cells["C" + RowIndex].Value = subjects.ElementAt(i).FullName; GeneralWorksheet.Cells["D" + RowIndex].Value = numabsent.Count(r => r == subjects.ElementAt(i).SubjectID); } //set border table for (int column = 2; column <= 4; column++) { for (int row = 9; row <= 9 + subjects.Count(); row++) { GeneralWorksheet.Cells[row, column].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.Black); } } //set height , width GeneralWorksheet.Cells["C2:D2"].Merge = true; GeneralWorksheet.Cells["C2:D2"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; GeneralWorksheet.Column(2).Width = 8; GeneralWorksheet.Column(3).Width = 47; GeneralWorksheet.Column(4).Width = 53; return GeneralWorksheet; }
public void ValidateEmailAddress(Student student) { IsEmailValid(student); IsEmailAvailable(student); IsContactNumberValid(student); }
public async ValueTask <Student> PostStudentAsync(Student student) => await this.apiFactoryClient.PostContentAsync(StudentsRelativeUrl, student);
public bool Save(Student student) { return(_studentGateway.Save(student)); }
/// <summary> /// 根据学生视图模型创建或者维护与之匹配的用户数据,并进行持久化处理 /// 1.缺省用户名采用学号数据 /// 2.缺省密码:1234@Abcd /// </summary> /// <param name="student"></param> /// <returns></returns> public async Task <EntityProcessResult> CreateOrEditByStudent(Student student, string userName = null) { var result = new EntityProcessResult() { Succeeded = true, Messages = new List <string> { } }; if (student.User == null) { // 检查重名 var checkName = student.EmployeeCode; if (!String.IsNullOrEmpty(userName)) { checkName = userName; } var isUniquelyForName = await IsUniquelyForUserName(checkName); if (isUniquelyForName) { var user = new ApplicationUser() { UserName = student.EmployeeCode, ChineseFullName = student.Name, Email = student.Email, MobileNumber = student.Mobile }; if (!String.IsNullOrEmpty(userName)) { user.UserName = userName; } var createResult = await _userManager.CreateAsync(user, "1234@Abcd"); result.BusinessObject = user; if (createResult.Succeeded) { student.User = user; await _studentRepository.AddOrEditAndSaveAsyn(student); // 提取用户缺省归属角色组(班级角色组) if (student.GradeAndClass != null) { var gradeAndClass = await _gradeAndClassRepository.GetSingleAsyn(student.GradeAndClass.Id, x => x.ApplicationRole); if (gradeAndClass.ApplicationRole != null) { await _userManager.AddToRoleAsync(student.User, gradeAndClass.ApplicationRole.Name); // 检查用户关联角色组类型声明 var userClaims = await _userManager.GetClaimsAsync(student.User); var userRoleTypeClaim = userClaims.FirstOrDefault(x => x.Type == ClaimTypes.Name && x.Value == gradeAndClass.ApplicationRole.ApplicationRoleType.ToString()); // 添加角色组类型声明 if (userRoleTypeClaim == null) { // 为用户创建一个归属系统角色类型的身份声明 var claim = new Claim(ClaimTypes.Name, gradeAndClass.ApplicationRole.ApplicationRoleType.ToString()); await _userManager.AddClaimAsync(student.User, claim); } } } // 加入缺省的角色组 var defaultRole = _roleManager.Roles.FirstOrDefault(x => x.ApplicationRoleType == ApplicationRoleTypeEnum.适用于普通注册用户); if (defaultRole != null) { await _userManager.AddToRoleAsync(student.User, defaultRole.Name); } } } else { result.Succeeded = false; result.Messages.Add("提交的用户名已经存在,请检查相关的数据!"); return(result); } } else { student.User.UserName = student.EmployeeCode; student.User.ChineseFullName = student.Name; student.User.Email = student.Email; student.User.MobileNumber = student.Mobile; if (!String.IsNullOrEmpty(userName)) { student.User.UserName = userName; } var editResult = await _userManager.UpdateAsync(student.User); result.BusinessObject = student.User; if (editResult.Succeeded) { await _studentRepository.AddOrEditAndSaveAsyn(student); // 提取用户缺省归属角色组(班级角色组) if (student.GradeAndClass != null) { var gradeAndClass = await _gradeAndClassRepository.GetSingleAsyn(student.GradeAndClass.Id, x => x.ApplicationRole); if (gradeAndClass.ApplicationRole != null) { await _userManager.AddToRoleAsync(student.User, gradeAndClass.ApplicationRole.Name); // 检查用户关联角色组类型声明 var userClaims = await _userManager.GetClaimsAsync(student.User); var userRoleTypeClaim = userClaims.FirstOrDefault(x => x.Type == ClaimTypes.Name && x.Value == gradeAndClass.ApplicationRole.ApplicationRoleType.ToString()); // 添加角色组类型声明 if (userRoleTypeClaim == null) { // 为用户创建一个归属系统角色类型的身份声明 var claim = new Claim(ClaimTypes.Name, gradeAndClass.ApplicationRole.ApplicationRoleType.ToString()); await _userManager.AddClaimAsync(student.User, claim); } } } } else { result.Succeeded = false; result.Messages.Add("更新用户组数据保存出现异常,请联系相关人员处理!"); foreach (var err in editResult.Errors) { result.Messages.Add(err.Description); } return(result); } } return(result); }
public int GetNumberOfStudent(Student student) { return(_studentGateway.GetNumberOfStudent(student)); }
public JsonResult UpdateStudentRecord(Student stdn) { Console.WriteLine("In updateStudentRecord"); return(Json(StudentRegistration.getInstance().UpdateStudent(stdn))); }
/// <summary> /// adding student /// </summary> /// <param name="name"></param> /// <returns></returns> public bool AddStudent(Student name) { duplicatePrevent(name.Id); student.Add(name); return(true); }
public IActionResult updatesubmit(ListModel data, string ctrl) { if (string.IsNullOrEmpty(HttpContext.Session.GetString("Session1"))) { return(RedirectToAction("UserLogin", "Login")); } if (ModelState.IsValid) { using (var transaction = _context.Database.BeginTransaction()) { try { Student student = null; IFormFile uploadedImage = data.EnrollModel.files; if (data.EnrollModel.StId.HasValue) { if (uploadedImage == null || uploadedImage.ContentType.ToLower().StartsWith("image/")) { MemoryStream ms = new MemoryStream(); uploadedImage.OpenReadStream().CopyTo(ms); System.Drawing.Image image = System.Drawing.Image.FromStream(ms); data.ctrl1 = 1; ViewBag.display = "div2"; student = _context.Student.Find(data.EnrollModel.StId); student.Dob = data.EnrollModel.Dob; student.EmailId = data.EnrollModel.EmailId; student.Gender = data.EnrollModel.Gender; student.MotherName = data.EnrollModel.MotherName; student.MotherOccu = data.EnrollModel.MotherOccu; student.MotherPhone = data.EnrollModel.MotherPhone; student.MotherQualification = data.EnrollModel.MotherQualification; student.MotherWhatsapp = data.EnrollModel.MotherWhatsapp; student.Nationality = data.EnrollModel.Nationality; student.Occupation = data.EnrollModel.Occupation; student.ParentMobile = data.EnrollModel.ParentMobile; student.ParentName = data.EnrollModel.ParentName; student.ParentWhatsappNo = data.EnrollModel.ParentWhatsappNo; student.POB = data.EnrollModel.POB; student.Qualification = data.EnrollModel.Qualification; student.StId = data.EnrollModel.StId.Value; student.StName = data.EnrollModel.StName; student.Address = data.EnrollModel.Address; if (uploadedImage != null) { student.Id = Guid.NewGuid(); student.Name = uploadedImage.FileName; student.Data = ms.ToArray(); student.Width = image.Width; student.Height = image.Height; student.ContentType = uploadedImage.ContentType; } _context.Entry(student).State = EntityState.Modified; _context.SaveChanges(); } } transaction.Commit(); // TempData["emodel"] = data; ViewBag.display = "div4"; ViewBag.student = student; return(View("updatestudent", data)); } catch (Exception e1) { transaction.Rollback(); fillinitialdata(); return(View("updatestudent", data)); } } } else { if (data.EnrollModel.StId.HasValue) { List <EnrollModel> list = Fill_Adlist(data.EnrollModel.StName); data.AdId = data.EnrollModel.AdId.Value; data.UserSearch = new UserSearch() { St_Name = data.EnrollModel.StName }; data.EnrollModels = list; fillinitialdata(); data.ctrl1 = 1; var res1 = _context.FeeType.Where(d => d.FTId == data.EnrollModel.FTId); ViewData["FTId"] = new SelectList(res1, "FTId", "Feetype1"); ViewBag.display = "div2"; ViewBag.studentdiv = "div3"; // return View("Indexdemo", data); } else { data.ctrl1 = 0; ViewBag.display = "div1"; var res1 = _context.FeeType.Where(d => d.FTId == data.EnrollModel.FTId); ViewData["FTId"] = new SelectList(res1, "FTId", "Feetype1"); fillinitialdata(); } ViewBag.domdata = data.EnrollModel.divdata; return(View("Indexdemo", data)); } }
public void SaveStudent(Student student, Gurdian gurdian, Action <Student> callBack) { student.Gurdians.Add(gurdian); AddAsync(student, callBack); }
public async Task <IActionResult> AddStudent(Student student) { await _studentService.Create(student.FirstName, student.LastName); return(RedirectToAction("Index")); }
public IActionResult selectadmission(ListModel listModel, string id) { if (string.IsNullOrEmpty(HttpContext.Session.GetString("Session1"))) { return(RedirectToAction("UserLogin", "Login")); } Admission1 admission = _context.Admission1.Find(listModel.AdId); Student student = _context.Student.Find(admission.StId); var res = _context.Admissiopay.Where(d => d.AdId == admission.AdId); listModel.EnrollModel = new EnrollModel() { StdId = admission.StdId, FTId = admission.FTId, FeeYear = admission.FeeYear, AdId = admission.AdId, StId = student.StId, POB = student.POB, StName = student.StName, Dob = student.Dob, EmailId = student.EmailId, Gender = student.Gender, MotherName = student.MotherName, MotherOccu = student.MotherOccu, MotherPhone = student.MotherPhone, MotherQualification = student.MotherQualification, MotherWhatsapp = student.MotherWhatsapp, Nationality = student.Nationality, Occupation = student.Occupation, ParentMobile = student.ParentMobile, ParentName = student.ParentName, ParentWhatsappNo = student.ParentWhatsappNo, Qualification = student.Qualification, Address = student.Address }; listModel.EnrollModel.paystatusid = ""; foreach (var item in res) { if (item.Paystatus == true) { listModel.EnrollModel.paystatusid += item.AdTId + "." + item.PayDate; if (item.Pay_mode == "Cash") { listModel.EnrollModel.paystatusid += ".1"; } else if (item.Pay_mode == "Cheque") { listModel.EnrollModel.paystatusid += ".2"; listModel.EnrollModel.paystatusid += "." + item.Chequeno; listModel.EnrollModel.paystatusid += "." + item.Chequedt.ToString(); listModel.EnrollModel.paystatusid += "." + item.BankName; listModel.EnrollModel.paystatusid += "." + item.BankBranch; } else if (item.Pay_mode == "netbanking") { listModel.EnrollModel.paystatusid += ".3"; listModel.EnrollModel.paystatusid += "." + item.Transactionno; } listModel.EnrollModel.paystatusid += ","; } } ViewBag.enrolldata = listModel.EnrollModel; ViewBag.display = "div2"; ViewBag.studentdiv = "div3"; List <EnrollModel> list = Fill_Adlist(student.StName); listModel.UserSearch = new UserSearch() { St_Name = student.StName }; listModel.EnrollModels = list; fillinitialdata(); if (id == "update") { return(View("UpdateStudent", listModel)); } else { return(View("FeePay", listModel)); } }
static void Main(string[] args) { Console.WriteLine("==学生学号不少于3位===班级编号不少于2位=="); int n; //定义参赛学生个数 int m; //定义参赛班级个数 Console.WriteLine("\t请问有几个参赛班级:"); m = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("========================================="); Clas[] cl = new Clas[m]; for (int i = 0; i < cl.Length; i++) { Console.WriteLine("\t请输入第{0}个班级的编号:", i + 1); cl[i].cID = Console.ReadLine(); Console.WriteLine("========================================="); } Console.WriteLine("\t请问有几个学生:"); n = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("========================================="); Student[] stu = new Student[n]; for (int i = 0; i < stu.Length; i++) { Console.WriteLine("\t请输入第{0}位学生的信息", i + 1); Console.Write("学号:"); stu[i].sID = Console.ReadLine(); Console.Write("姓名:"); stu[i].sName = Console.ReadLine(); Console.Write("分数:"); stu[i].sScore = float.Parse(Console.ReadLine()); Console.WriteLine("========================================="); } for (int i = 0; i < stu.Length; i++) { Console.Write("第{0}位学生信息:", i + 1); Console.WriteLine("\t学号:" + stu[i].sID); Console.WriteLine("\t\t姓名:" + stu[i].sName); Console.WriteLine("\t\t分数:" + stu[i].sScore); Console.WriteLine("========================================="); } //求班级总成绩 for (int i = 0; i < stu.Length; i++) { for (int j = 0; j < cl.Length; j++) { if ((stu[i].sID.Substring(0, 2) == cl[j].cID)) { cl[j].cScore += stu[i].sScore; } } } Console.WriteLine("\t{0}个班的总成绩分别是:\n", cl.Length); for (int i = 0; i < cl.Length; i++) { Console.WriteLine("\t班级编号:{0},班级总成绩:{1}", cl[i].cID, cl[i].cScore); Console.WriteLine("========================================="); } //班级总成绩排序====反冒泡排序==== for (int i = 1; i < cl.Length; i++) { for (int j = 1; j <= cl.Length - i; j++) { if (cl[j].cScore > cl[j - 1].cScore) { float cScoretemp; string cIDtemp; cScoretemp = cl[j - 1].cScore; cIDtemp = cl[j - 1].cID; cl[j - 1].cScore = cl[j].cScore; cl[j - 1].cID = cl[j].cID; cl[j].cScore = cScoretemp; cl[j].cID = cIDtemp; } } } Console.WriteLine("\t{0}个班的总成绩排名是:\n", cl.Length); for (int i = 0; i < cl.Length; i++) { Console.WriteLine("\t班级编号:{0},班级总成绩:{1}", cl[i].cID, cl[i].cScore); Console.WriteLine("========================================="); } //学生个人成绩排序====反冒泡排序==== for (int i = 1; i < stu.Length; i++) { for (int j = 1; j <= stu.Length - i; j++) { if (stu[j].sScore > stu[j - 1].sScore) { float sScoretemp; string sIDtemp; string sNametemp; sScoretemp = stu[j - 1].sScore; sIDtemp = stu[j - 1].sID; sNametemp = stu[j - 1].sName; stu[j - 1].sScore = stu[j].sScore; stu[j - 1].sID = stu[j].sID; stu[j - 1].sName = stu[j].sName; stu[j].sScore = sScoretemp; stu[j].sID = sIDtemp; stu[j].sName = sNametemp; } } } Console.WriteLine("\t{0}个学生成绩排名是:\n", stu.Length); for (int i = 0; i < stu.Length; i++) { Console.WriteLine("\t学生学号:{0},学生姓名:{1},学生分数:{2}", stu[i].sID, stu[i].sName, stu[i].sScore); Console.WriteLine("========================================="); } Console.ReadKey(); }
public async Task <IActionResult> Create(ListModel data, string ctrl) { if (string.IsNullOrEmpty(HttpContext.Session.GetString("Session1"))) { return(RedirectToAction("UserLogin", "Login")); } if (ModelState.IsValid) { using (var transaction = _context.Database.BeginTransaction()) { try { Student student; if (data.EnrollModel.StId.HasValue) { if (data.EnrollModel.files != null) { IFormFile uploadedImage = null; MemoryStream ms = null; uploadedImage = data.EnrollModel.files; System.Drawing.Image image = null; if (uploadedImage != null || uploadedImage.ContentType.ToLower().StartsWith("image/")) { ms = new MemoryStream(); uploadedImage.OpenReadStream().CopyTo(ms); image = System.Drawing.Image.FromStream(ms); } data.ctrl1 = 1; ViewBag.display = "div2"; student = _context.Student.Find(data.EnrollModel.StId); student.Dob = data.EnrollModel.Dob; student.EmailId = data.EnrollModel.EmailId; student.Gender = data.EnrollModel.Gender; student.MotherName = data.EnrollModel.MotherName; student.MotherOccu = data.EnrollModel.MotherOccu; student.MotherPhone = data.EnrollModel.MotherPhone; student.MotherQualification = data.EnrollModel.MotherQualification; student.MotherWhatsapp = data.EnrollModel.MotherWhatsapp; student.Nationality = data.EnrollModel.Nationality; student.Occupation = data.EnrollModel.Occupation; student.ParentMobile = data.EnrollModel.ParentMobile; student.ParentName = data.EnrollModel.ParentName; student.ParentWhatsappNo = data.EnrollModel.ParentWhatsappNo; student.POB = data.EnrollModel.POB; student.Qualification = data.EnrollModel.Qualification; student.StId = data.EnrollModel.StId.Value; student.StName = data.EnrollModel.StName; student.Address = data.EnrollModel.Address; if (uploadedImage != null) { student.Id = Guid.NewGuid(); student.Name = uploadedImage.FileName; student.Data = ms.ToArray(); student.Width = image.Width; student.Height = image.Height; student.ContentType = uploadedImage.ContentType; } _context.Entry(student).State = EntityState.Modified; _context.SaveChanges(); } } else { data.ctrl1 = 0; ViewBag.display = "div1"; IFormFile uploadedImage = data.EnrollModel.files; if (uploadedImage != null || uploadedImage.ContentType.ToLower().StartsWith("image/")) { MemoryStream ms = new MemoryStream(); uploadedImage.OpenReadStream().CopyTo(ms); System.Drawing.Image image = System.Drawing.Image.FromStream(ms); // fillinitialdata(); student = new Student() { StName = data.EnrollModel.StName, ParentName = data.EnrollModel.ParentName, Dob = data.EnrollModel.Dob, EmailId = data.EnrollModel.EmailId, ParentMobile = data.EnrollModel.ParentMobile, Gender = data.EnrollModel.Gender, MotherName = data.EnrollModel.MotherName, MotherOccu = data.EnrollModel.MotherOccu, MotherPhone = data.EnrollModel.MotherPhone, MotherQualification = data.EnrollModel.MotherQualification, MotherWhatsapp = data.EnrollModel.MotherWhatsapp, Nationality = data.EnrollModel.Nationality, Occupation = data.EnrollModel.Occupation, ParentWhatsappNo = data.EnrollModel.ParentWhatsappNo, POB = data.EnrollModel.POB, Qualification = data.EnrollModel.Qualification, Address = data.EnrollModel.Address, Id = Guid.NewGuid(), Name = uploadedImage.FileName, Data = ms.ToArray(), Width = image.Width, Height = image.Height, ContentType = uploadedImage.ContentType }; _context.Student.Add(student); _context.SaveChanges(); data.EnrollModel.StId = student.StId; } } Admission1 admission = new Admission1() { StId = data.EnrollModel.StId, StdId = data.EnrollModel.StdId, FTId = data.EnrollModel.FTId, FeeYear = data.EnrollModel.FeeYear }; _context.Admission1.Add(admission); _context.SaveChanges(); data.AdId = admission.AdId; data.EnrollModel.paystatusid = data.EnrollModel.paystatusid.Remove(data.EnrollModel.paystatusid.Length - 1, 1); string[] paidid = data.EnrollModel.paystatusid.Split(","); //var res= _context.Admissiopay.Where(p => p.AdId == admission.AdId); // foreach (var item in res) // { foreach (var item1 in paidid) { string[] modes = item1.Split("."); var res = _context.Admissiopay.Find(admission.AdId, Convert.ToInt32(modes[0])); res.Paystatus = true; res.PayDate = Convert.ToDateTime(modes[1]); if (modes[2].ToString() == "1") { res.Pay_mode = "Cash"; } else if (modes[2].ToString() == "2") { res.Pay_mode = "Cheque"; res.Chequeno = modes[3].ToString(); res.Chequedt = Convert.ToDateTime(modes[4]); res.BankName = modes[5].ToString(); res.BankBranch = modes[6].ToString(); } else if (modes[2].ToString() == "3") { res.Pay_mode = "netbanking"; res.Transactionno = modes[3].ToString(); } _context.SaveChanges(); } transaction.Commit(); // TempData["emodel"] = data; ViewBag.display = "div4"; ViewBag.ADID = data.AdId; return(View("Indexdemo", data)); //return RedirectToAction("printreceiptdemo", "Admission", new { ID1 = data.AdId}); } catch (SqlException e) { transaction.Rollback(); fillinitialdata(); return(View("Indexdemo", data)); } catch (Exception e1) { fillinitialdata(); return(View("Indexdemo", data)); } } } else { if (data.EnrollModel.StId.HasValue) { List <EnrollModel> list = Fill_Adlist(data.EnrollModel.StName); data.AdId = data.EnrollModel.AdId.Value; data.UserSearch = new UserSearch() { St_Name = data.EnrollModel.StName }; data.EnrollModels = list; fillinitialdata(); data.ctrl1 = 1; var res1 = _context.FeeType.Where(d => d.FTId == data.EnrollModel.FTId); ViewData["FTId"] = new SelectList(res1, "FTId", "Feetype1"); ViewBag.display = "div2"; ViewBag.studentdiv = "div3"; // return View("Indexdemo", data); } else { data.ctrl1 = 0; ViewBag.display = "div1"; var res1 = _context.FeeType.Where(d => d.FTId == data.EnrollModel.FTId); ViewData["FTId"] = new SelectList(res1, "FTId", "Feetype1"); fillinitialdata(); } ViewBag.domdata = data.EnrollModel.divdata; return(View("Indexdemo", data)); } }
public static void Initialize(SchoolContext context) { context.Database.EnsureCreated(); // Look for any students. if (context.Students.Any()) { return; // DB has been seeded } var students = new Student[] { new Student { FirstMidName = "Carson", LastName = "Alexander", EnrollmentDate = DateTime.Parse("2005-09-01") }, new Student { FirstMidName = "Meredith", LastName = "Alonso", EnrollmentDate = DateTime.Parse("2002-09-01") }, new Student { FirstMidName = "Arturo", LastName = "Anand", EnrollmentDate = DateTime.Parse("2003-09-01") }, new Student { FirstMidName = "Gytis", LastName = "Barzdukas", EnrollmentDate = DateTime.Parse("2002-09-01") }, new Student { FirstMidName = "Yan", LastName = "Li", EnrollmentDate = DateTime.Parse("2002-09-01") }, new Student { FirstMidName = "Peggy", LastName = "Justice", EnrollmentDate = DateTime.Parse("2001-09-01") }, new Student { FirstMidName = "Laura", LastName = "Norman", EnrollmentDate = DateTime.Parse("2003-09-01") }, new Student { FirstMidName = "Nino", LastName = "Olivetto", EnrollmentDate = DateTime.Parse("2005-09-01") } }; foreach (Student s in students) { context.Students.Add(s); } context.SaveChanges(); var courses = new Course[] { new Course { CourseID = 1050, Title = "Chemistry", Credits = 3 }, new Course { CourseID = 4022, Title = "Microeconomics", Credits = 3 }, new Course { CourseID = 4041, Title = "Macroeconomics", Credits = 3 }, new Course { CourseID = 1045, Title = "Calculus", Credits = 4 }, new Course { CourseID = 3141, Title = "Trigonometry", Credits = 4 }, new Course { CourseID = 2021, Title = "Composition", Credits = 3 }, new Course { CourseID = 2042, Title = "Literature", Credits = 4 } }; foreach (Course c in courses) { context.Courses.Add(c); } context.SaveChanges(); var enrollments = new Enrollment[] { new Enrollment { StudentID = 1, CourseID = 1050, Grade = Grade.A }, new Enrollment { StudentID = 1, CourseID = 4022, Grade = Grade.C }, new Enrollment { StudentID = 1, CourseID = 4041, Grade = Grade.B }, new Enrollment { StudentID = 2, CourseID = 1045, Grade = Grade.B }, new Enrollment { StudentID = 2, CourseID = 3141, Grade = Grade.F }, new Enrollment { StudentID = 2, CourseID = 2021, Grade = Grade.F }, new Enrollment { StudentID = 3, CourseID = 1050 }, new Enrollment { StudentID = 4, CourseID = 1050 }, new Enrollment { StudentID = 4, CourseID = 4022, Grade = Grade.F }, new Enrollment { StudentID = 5, CourseID = 4041, Grade = Grade.C }, new Enrollment { StudentID = 6, CourseID = 1045 }, new Enrollment { StudentID = 7, CourseID = 3141, Grade = Grade.A }, }; foreach (Enrollment e in enrollments) { context.Enrollments.Add(e); } context.SaveChanges(); }
//GET: AddStudent public IActionResult AddStudent() { var student = new Student(); return(View(student)); }
public static void Add(Student student) { student.StudentId = _students.Count + 1; _students.Add(student); }
public static void Initialize(HighSchoolContext context) { // Look for any teachers if (context.Teachers.Any()) { return; // DB has been seeded } // seed teachers var teachers = new Teacher[] { new Teacher { Name = "Admin", Birthday = DateTime.Parse("1998-11-30") }, }; foreach (Teacher t in teachers) { context.Teachers.Add(t); } context.SaveChanges(); // seed roles var roles = new IdentityRole[] { new IdentityRole { Name = "Admin", NormalizedName = "ADMIN" }, new IdentityRole { Name = "Manager", NormalizedName = "MANAGER" }, new IdentityRole { Name = "Teacher", NormalizedName = "TEACHER" } }; foreach (IdentityRole role in roles) { context.Roles.Add(role); } context.SaveChanges(); // seed admmin var teacher = context.Teachers.Where(t => t.Name.Equals("Admin")).FirstOrDefault(); var user = new ApplicationUser { UserName = "******", NormalizedUserName = "******", TeacherID = teacher.TeacherID }; if (!context.Users.Any(u => u.UserName == user.UserName)) { var password = new PasswordHasher <ApplicationUser>(); var hashed = password.HashPassword(user, "123456"); user.PasswordHash = hashed; context.Users.Add(user); } context.SaveChanges(); // set role for user var aUser = context.Users.Where(u => u.UserName.Equals("Admin")).FirstOrDefault(); var aRole = context.Roles.Where(r => r.Name.Equals("Admin")).FirstOrDefault(); var userRole = new IdentityUserRole <string> { UserId = aUser.Id, RoleId = aRole.Id }; context.UserRoles.Add(userRole); context.SaveChanges(); // seed grades var grades = new Grade[] { new Grade { Name = "12" }, new Grade { Name = "11" }, new Grade { Name = "10" } }; foreach (Grade g in grades) { context.Grades.Add(g); } context.SaveChanges(); // seed school years var semesters = new Semester[] { new Semester { Label = 2, Year = 2018 }, new Semester { Label = 1, Year = 2018 }, }; foreach (Semester s in semesters) { context.Semesters.Add(s); } context.SaveChanges(); // seed result types var resultTypes = new ResultType[] { new ResultType { Name = "Exam", Coefficient = 3 }, new ResultType { Name = "45' Test", Coefficient = 2 }, new ResultType { Name = "15' Test", Coefficient = 1 }, }; foreach (ResultType rT in resultTypes) { context.ResultTypes.Add(rT); } context.SaveChanges(); // seed subjects var subjects = new Subject[] { new Subject { Name = "English" }, new Subject { Name = "Math" }, new Subject { Name = "Physics" }, new Subject { Name = "Chemistry" }, new Subject { Name = "Biology" }, new Subject { Name = "History" }, new Subject { Name = "Geography" }, new Subject { Name = "Literature" }, new Subject { Name = "Civic" }, new Subject { Name = "Information Technology" }, new Subject { Name = "Physical Education" }, }; foreach (Subject s in subjects) { context.Subjects.Add(s); } context.SaveChanges(); // seed students var students = new Student[] { new Student { LastName = "Nguyễn Văn", FirstName = "Aaa", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Bbb", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Ccc", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Ddd", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Eee", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Fff", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Ggg", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Hhh", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Iii", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Jjj", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Kkk", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Lll", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Mmm", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Nnn", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Ooo", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Ppp", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Qqq", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Rrr", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Sss", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Ttt", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Uuu", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Vvv", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Www", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Xaxa", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Yyy", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Zzz", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "An", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Bình", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Cường", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Danh", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Em", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "F'ao", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Giang", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Hoàng", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Iến", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Jankos", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Khoa", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Linh", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Minh", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Ngân", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Ông", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Phương", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Quân", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Ram", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Sang", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Trang", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Uyên", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Vân", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Wub", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Xuân", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Yến", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Zap", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Một", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Hai", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Ba", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Bốn", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Năm", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Sáu", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Bảy", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Tám", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Nguyễn Văn", FirstName = "Chín", Gender = "Male", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, new Student { LastName = "Trần Văn", FirstName = "Mười", Gender = "Female", Birthday = DateTime.Parse("2005-01-01"), Address = "123 Everywhere" }, }; foreach (Student s in students) { context.Students.Add(s); } context.SaveChanges(); }
public StudentWithGroup(Student student, string groupName) : base(student.FirstName, student.LastName, student.Age, student.FacultyNumber, student.Phone, student.Email, student.Marks, student.GroupNumber) { this.GroupName = groupName; }
public ActionResult ChooseCoursePage(string courseTypeName) { if (courseTypeName == null || courseTypeName.Equals("")) { return(View("Error")); } Login login = (Login)Session["loginInfo"]; if (login == null) { //未登录 //跳转到登录页面 Session["prePage"] = "/Student/Index";//将当前页面地址放入session,登录后返回到该页面 return(RedirectToAction("Index", "Login")); } Student student = studentService.GetStudentById(login.username); string collegeId = student.college_id; //学生可以选择任意学院的公共选修课,所以不需要指定学院id if (courseTypeName.Equals("公共选修课")) { collegeId = null; } //所有相应课程类型的课程 IList <Teacher_course> teacher_courses_all = courseService.SelectTeacherCourseList(courseTypeName, collegeId); IList <Course_choosing> course_choosings = courseService.SelectCourseChoosingListByStu(student.student_id); IList <Teacher_course> teacher_courses = new List <Teacher_course>(); //筛选teacher_courses_all中还没选的课程,并且查询出课程信息 foreach (Teacher_course t_course in teacher_courses_all) { Course course = courseService.SelectCourseById(t_course.course_id); t_course.College = courseService.SelectCollegeById(course.college_id); t_course.Course = course; for (int i = 0; i < course_choosings.Count; i++) { Course_choosing course_Choosing = course_choosings[i]; if (!course_Choosing.course_id.Equals(t_course.course_id)) { if (i == (course_choosings.Count - 1)) { teacher_courses.Add(t_course); } else { continue; } } else { //该课程已经被选过了 break; } } } if (course_choosings.Count == 0) { //如果没有已选课程 teacher_courses = teacher_courses_all; } //查询course_choosings中的课程信息 IList <Course> choosedCourseList = new List <Course>(); foreach (Course_choosing course_chooseing in course_choosings) { Course course = courseService.SelectCourseById(course_chooseing.course_id); choosedCourseList.Add(course); } ViewData["teacher_courses"] = teacher_courses; ViewData["course_choosings"] = choosedCourseList; return(View()); }
public void TestComplexModel() { // load environment variables from .env DotNetEnv.Env.Load(); /* Insert a complex model with foreign model relationships * <- means depends foreign model * Lecturer <- Student <- ProjectMembers -> Project */ int lecturerId = -1; using (EPortfolioDB database = new EPortfolioDB()) { // Lecturer model Lecturer lecturer = LecturerTest.GetSampleLecturer(); database.Lecturers.Add(lecturer); // Student model Student student = StudentTest.GetSampleStudent(); student.Mentor = lecturer; database.Students.Add(student); // Project model Project project = ProjectTest.GetSampleProject(); database.Projects.Add(project); // ProjectMember model ProjectMember projectMember = new ProjectMember { Member = student, Project = project, Role = "Member" }; database.ProjectMembers.Add(projectMember); database.SaveChanges(); lecturerId = lecturer.LecturerId; } // query complex model using (EPortfolioDB database = new EPortfolioDB()) { Lecturer lecturer = database.Lecturers .Where(l => l.LecturerId == lecturerId) .Include(l => l.Students) .ThenInclude(s => s.ProjectMembers) .ThenInclude(pm => pm.Project) .Single(); Assert.True(LecturerTest.CheckSampleLecturer(lecturer), "lecturer obtained from DB inconsistent with one inserted " + "into the db"); Student student = lecturer.Students.First(); Assert.True(StudentTest.CheckSampleStudent(student), "student obtained from DB inconsistent with one inserted " + "into the db"); ProjectMember projectMember = lecturer.Students.First() .ProjectMembers.First(); Assert.Equal("Member", projectMember.Role); Project project = projectMember.Project; Assert.True(ProjectTest.CheckSampleProject(project), "project obtained from DB inconsistent with one inserted " + "into the db"); // cleanup database.ProjectMembers.Remove(projectMember); database.Projects.Remove(project); database.Students.Remove(student); database.Lecturers.Remove(lecturer); database.SaveChanges(); } }
public PasswordDialog(Student user) { InitializeComponent(); newPwdMode = false; student = user ?? throw new ArgumentNullException(nameof(user)); }
public async Task ShouldAddStudentViewAsync() { //given Guid randomUserId = Guid.NewGuid(); DateTimeOffset randomDateTime = GetRandomDate(); dynamic randomStudentViewProperties = CreateRandomStudentViewProperties( auditDates: randomDateTime, auditIds: randomUserId); var randomStudentView = new StudentView { IdentityNumber = randomStudentViewProperties.IdentityNumber, FirstName = randomStudentViewProperties.FirstName, MiddleName = randomStudentViewProperties.MiddleName, LastName = randomStudentViewProperties.LastName, Gender = randomStudentViewProperties.GenderView, BirthDate = randomStudentViewProperties.BirthDate }; StudentView inputStudentView = randomStudentView; StudentView expectedStudentView = inputStudentView; var randomStudent = new Student { Id = randomStudentViewProperties.Id, UserId = randomStudentViewProperties.UserId, IdentityNumber = randomStudentViewProperties.IdentityNumber, FirstName = randomStudentViewProperties.FirstName, MiddleName = randomStudentViewProperties.MiddleName, LastName = randomStudentViewProperties.LastName, Gender = randomStudentViewProperties.Gender, BirthDate = randomStudentViewProperties.BirthDate, CreatedBy = randomUserId, UpdatedBy = randomUserId, CreatedDate = randomDateTime, UpdatedDate = randomDateTime }; Student expectedInputStudent = randomStudent; Student returnedStudent = expectedInputStudent; this.userServiceMock.Setup(service => service.GetCurrentlyLoggedInUser()) .Returns(randomUserId); this.dateTimeBrokerMock.Setup(broker => broker.GetCurrentDateTime()) .Returns(randomDateTime); this.studentServiceMock.Setup(service => service.RegisterStudentAsync(It.Is( SameStudentAs(expectedInputStudent)))) .ReturnsAsync(returnedStudent); //when StudentView actualStudentView = await this.studentViewService.AddStudentViewAsync(inputStudentView); //then actualStudentView.Should().BeEquivalentTo(expectedStudentView); this.userServiceMock.Verify(service => service.GetCurrentlyLoggedInUser(), Times.Once); this.dateTimeBrokerMock.Verify(broker => broker.GetCurrentDateTime(), Times.Once); this.studentServiceMock.Verify(service => service.RegisterStudentAsync(It.Is( SameStudentAs(expectedInputStudent))), Times.Once); this.dateTimeBrokerMock.VerifyNoOtherCalls(); this.userServiceMock.VerifyNoOtherCalls(); this.studentServiceMock.VerifyNoOtherCalls(); this.loggingBrokerMock.VerifyNoOtherCalls(); }
public StudentWithGroup(Student student) : base(student.FirstName, student.LastName, student.Age, student.FacultyNumber, student.Phone, student.Email, student.Marks, student.GroupNumber) { }